Changes

Jump to: navigation, search

Visual Basic Modules and Procedures

1,248 bytes added, 19:38, 30 July 2007
Visual Basic Procedures
Now that we have added a new module to our project the next step is to add Visual Basic code to that module. Before we can do that, however, we need to learn about Visual Basic ''procedures''.
== Visual Basic Code Procedures == Visual Basic procedures provide a way to break up code into logical and re-usable sections that can be called from other sections of Visual Basic code. For example, you might have a section of Visual Basic code which calculates the interest due on a loan. It is also possible that you need to perform this calculation from a number of different places in your application code. Rather than duplicating the code to perform this task at each code location where it is needed, it is more efficient to place the calculation code in a procedure, and then ''call'' that procedure each time it is needed. Visual Basic provides two types of procedures: * '''functions'' - Functions are procedures which perform a task and return a value when completed. * '''subroutines'' - Subroutines are procedures which perform a task but return no value when completed. It is especially useful to be able to return values from ''functions''. For example, the function may need to return the result of the task it performed (perhaps the result of a calculation). A function might also return a True or False value to indicate when the task was performed successfully. The Visual Basic code which called the function then then act based on the returned value.

Navigation menu