There are four types of procedures in VB.
1. Sub procedures
2. Function Procedures
3. Visual Basic Procedures
4. Event based procedures
Visual Basic procedures are the built in procedures provided by the language. These procedures provide the most commonly used functionality. Built in procedures work fast then the equivalent procedures written by the VB programmers. It's a good practice to know and use the built in procedures instead of writing some new version.
Event based procedures are the procedures that are invoked when some event is triggered like 'mouse clicked' or 'key pressed' etc. Some code is written under the header that the programmer wants to be executed whenever the event triggers.
Sub procedures are the procedures that are written by the programmer to perform some specific function. They can be created by the IDE as well as through code. Add procedure dialog is used for this purpose. In the code view click 'Add Procedure' and then select the type of procedure as sub and then choose or the access modifier you need. 'Private' limits the access to the function to the form on which it is defined while 'Public' identifier makes the function available for other forms also. Mention the name of procedure in the name text box and click OK. You will see the following code in your code window.
Private Sub ProcedureName ()
End Sub
You have to write the code between Sub and 'End Sub' that you want. You can also write this code directly in the code window instead of using the dialog box. Any arguments that you want to pass to the procedure are to be mentioned between the parentheses.
Functions procedures are also created the same way the only difference between sub procedures and function procedures is that functions return some values whereas sub procedures do not. Normally functions are used for calculating purposes and to return the result of the calculation. For this reason the syntax also varies now you have to mention the return data type in the function header. The syntax will be as follows
Private FunctionName(Argument list) as ReturnType
End Fuction
1. Sub procedures
2. Function Procedures
3. Visual Basic Procedures
4. Event based procedures
Visual Basic procedures are the built in procedures provided by the language. These procedures provide the most commonly used functionality. Built in procedures work fast then the equivalent procedures written by the VB programmers. It's a good practice to know and use the built in procedures instead of writing some new version.
Event based procedures are the procedures that are invoked when some event is triggered like 'mouse clicked' or 'key pressed' etc. Some code is written under the header that the programmer wants to be executed whenever the event triggers.
Sub procedures are the procedures that are written by the programmer to perform some specific function. They can be created by the IDE as well as through code. Add procedure dialog is used for this purpose. In the code view click 'Add Procedure' and then select the type of procedure as sub and then choose or the access modifier you need. 'Private' limits the access to the function to the form on which it is defined while 'Public' identifier makes the function available for other forms also. Mention the name of procedure in the name text box and click OK. You will see the following code in your code window.
Private Sub ProcedureName ()
End Sub
You have to write the code between Sub and 'End Sub' that you want. You can also write this code directly in the code window instead of using the dialog box. Any arguments that you want to pass to the procedure are to be mentioned between the parentheses.
Functions procedures are also created the same way the only difference between sub procedures and function procedures is that functions return some values whereas sub procedures do not. Normally functions are used for calculating purposes and to return the result of the calculation. For this reason the syntax also varies now you have to mention the return data type in the function header. The syntax will be as follows
Private FunctionName(Argument list) as ReturnType
End Fuction