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.
Figure 3.1 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 3.1, 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.
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 .
Procedure to calculate the volume of cylinder for clicking the OK button
get the value of r from radius text box
get the value of h from height text box
assign a constant value 22/7 to the pi
calculate the volume using the formula
output the results to Volume text box
End of Procedure
The syntax radius.Text consists of two parts, radius is the name of text box while Text is the textual contents of the text box and generally, the syntax is: Object.Property In our example, the objects are radius, volume and hght, each having text as their property.Object and property is separated by a period(or dot) and thaen the contents of a text box can only be displayed in textual form, or in programming term,as string.You have to use the function Val to convert the contents of a text box to a numeric value so that mathematical operations can be performed. Finally, In order to display the results in a text box, we have to perform the reverse procedure, that is, to convert the numeric value back to textual form, using the function Str$.
I shall also explain the syntax that defines the sub procedure Private Sub OK_click and Private Sub here means that the parameters ,formulas and values that are used here belong only to the OK subprocedure(an object by itself).They cannot be used by other sub modules or procedures. OK_Click defines that what kind of action the subprocedure OK will response.Here, the action is mouse click and there are other kind of actions like keypress, keyup, keydown and etc that I am going to due with in other lessons.