Wednesday, 22 August 2018

The Control Properties in vb6

Before writing an event procedure for the control to response to a user's input,
you have to set certain properties for the control to determine its appearance
and how it will work with the event procedure. You can set the properties of the
controls in the properties window or at runtime.
In properties form1 Figure on the right is a typical properties window for a
form. You can rename the form caption to any name that you like best. In the
properties window, the item appears at the top part is the object currently
selected (in Figure, the object selected is Form1). At the bottom part, the items
listed in the left column represent the names of various properties associated
with the selected object while the items listed in the right column represent the
states of the properties. Properties can be set by highlighting the items in the
right column then change them by typing or selecting the options available.
For example, in order to change the caption, just highlight Form1 under the
name Caption and change it to other names. You may also try to alter the
appearance of the form by setting it to 3D or flat. Other things you can do are to
change its foreground and background color, change the font type and font size,
enable or disable minimize and maximize buttons and etc.
You can also change the properties at runtime to give special effects such
as change of color, shape, animation effect and so on. For example the
following code will change the form color to red every time the form is loaded.
VB uses hexadecimal system to represent the color. You can check the color
codes in the properties windows which are showed up under ForeColor and
BackColor .
Private Sub Form_Load()
Form1.Show
Form1.BackColor = &H000000FF&
End Sub
What are methods and properties?
All the controls in VB except the Pointer are objects in Visual Basic. These objects have associated with
properties and methods. Real world objects are loaded with properties. For example, a flower is loaded certain
color, shape and fragrance. Similarly programming objects are loaded with properties. A property is a named
attribute of a programming object. Properties define the characteristics of an object such as Size, Color etc. or
sometimes the way in which it behaves. For example, a TextBox accepts properties such as Enabled, Font,
MultiLine, Text, Visible, Width, etc.
The properties that are discussed above are design-time properties that can be set at the design time by selecting
the Properties Window. But certain properties cannot be set at design time. For example, the CurrentX and
CurrentY properties of a Form cannot be set at the design time.
A method is an action that can be performed on objects. For example, a cat is an object. Its properties might
include long white hair, blue eyes, 3 pounds weight etc. A complete definition of cat must only encompass on
its looks, but should also include a complete itemization of its activities. Therefore, a cat's methods might be
move, jump, play, breath etc.
Similarly in object-oriented programming, a method is a connected or built-in procedure, a block of code that
can be invoked to impart some action on a particular object. A method requires an object to provide them with a
context. For example, the word Move has no meaning in Visual Basic, but the statement,
Text1.Move 700, 400
performs a very precise action. The TextBox control has other associated methods such as Refresh, SetFocus,
etc.

No comments:

Post a Comment