Now, doubleclick on the O.K button and enter the codes between Private Sub OK_Click( ) and End Sub
I shall attempt to explain the above source program to newcomers in Visual
Basic( If you are a veteran, you can skip this part) . Let me describe the steps
using pseudocodes as follows: Procedure for clicking
the OK button to calculate the volume of cylinder get
the value of r from the radius text box get
the value of h from the height text box assign
a constant value 22/7 to pi calculate
the volume using formula output the
results to the 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. Generally, the syntax is: Object.Property
In our example, the objects are radius, hght and
volume, each having text as their property.Object
and property is separated by a period(or dot).The contents of a text box can
only be displayed in textual form, or in programming term,as string. To convert
the contents of a text box to a numeric value so that mathematical operations
can be performed , you have to use the function Val. 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 the textual
form, using the function Str$.
I shall also explain the syntax that defines the sub procedure Private Sub OK_click. Private Sub here means that the parameters , values and formulas that are used here belong only to the OK subprocedure(an object by itself).They cannot be used by other sub procedures or modules. OK_Click defines what kind of action the subprocedure OK will response .Here, the action is mouse click. There are other kind of actions like keypress, keyup, keydown and etc that I am going to due with in other lessons.