Changes

Jump to: navigation, search

Visual Basic Modules and Procedures

2 bytes added, 20:28, 31 July 2007
Defining Visual Basic Functions
</pre>
In the above Function, we accept two strings (value1 and value2), and declare an Integer variable called ''result'' to hold the result of the calculation. We then divide value1 by value2 and multiple multiply the result by 100 to get value1 as a percentage of value2. The result is assigned to the ''result'' variable and then returned to the code which called the function.
The final step, is to modify our Button control ''Click'' event procedure to call the ''PercentageOf()'' function, passing through the Text properties of our two TextBox controls. The result returned by this function is then passed to the ''DisplayResult()'' Subroutine where it is displayed in a message window:

Navigation menu