2 Answers - Sort by: Date | Rating
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
0
0
There are two kinds of procedures in VB, one is Sub procedure and other is Function procedure.All statements are defined between Sub and End Sub statements. It does not return any value and if arguments are passed by calling procedure then it can take it.
Example 1:
Sub hello()
statements ......
End Sub
If it take arguments then arguments are written as given below.
Sub hello(argument 1, argument 2)
statements ......
End Sub
Similarly, In a Function procedure all statements are defined between Function and End Function statements. A function procedure can return a value. Just like Sub Procedure a Function procedure if arguments are passed by calling procedure then it can take it.
Example 2:
Function Hello()
statements...
Hello= any value
End function
If it take arguments then arguments are written as given below.
Function Hello(arg1,arg2)
statements...
Hello= any value
End function
Basically, procedures are used for increasing the performance of a program. Procedures are very important in VB and i can say that it is not possible to write an application without using procedures. Main advantage of procedures is that you write the code for just one time and you can use it several times. Procedures divide a program into smaller parts so it is easy to read it and it also helps in debugging.
Example 1:
Sub hello()
statements ......
End Sub
If it take arguments then arguments are written as given below.
Sub hello(argument 1, argument 2)
statements ......
End Sub
Similarly, In a Function procedure all statements are defined between Function and End Function statements. A function procedure can return a value. Just like Sub Procedure a Function procedure if arguments are passed by calling procedure then it can take it.
Example 2:
Function Hello()
statements...
Hello= any value
End function
If it take arguments then arguments are written as given below.
Function Hello(arg1,arg2)
statements...
Hello= any value
End function
Basically, procedures are used for increasing the performance of a program. Procedures are very important in VB and i can say that it is not possible to write an application without using procedures. Main advantage of procedures is that you write the code for just one time and you can use it several times. Procedures divide a program into smaller parts so it is easy to read it and it also helps in debugging.
0
0
- Write A Java Program To Store A Number Find If It Is Positive Or A Negative Number If Positive Print I Am The First?
- Write A Java Program To Store 3 Numbers Find Sum And Product And Print It?
- Finds The Factorial Of The Numbers That Lie Between 1 And 10 Using Nested For Loop?
- What Is Polymorphism ? With Example
- How To Pull A Command Prompt?
- Where Can I Find Pdf Files Of The Old White Wolf Rpg Books?
- How To Create A Header File In C Language?
- What Is Difference Between HTML Vs XHTML?
- How The Efficiency And Integrity Of The Data Is Maintained At All?
- A Form In Visual Basic Is Best Described As What?
- How To Update The Sim 3 Expansion?
- Program To Calculate Change The Name To Write In Any Word In English And It Will Convert To Change Any Language Of User?
- What Are The Risks In Undertaking A Systems Analysis And Design Activity?
- Do While Loop In C++ Output?
- What Is File-based Approach?
- What Is Cascading Rollback?
- How Do I Create An SQL Queries That Show: Student Name, Address, And Contact Information For All Students? Student Name And The Certificate Program For Which They Are Registered Student Name And The Courses For Which They Are Registered?
- I Need To Create A System Where Students Can Register For One Of 5 Certificates, Select Courses, And Obtain A Transcript Of The Grades Received For The Courses. Each Student Can Be Enrolled For Only One Certificate. There Are 4 Courses In Each Cert?
- How The Efficiency And Integrity Of The Data Is Maintained At All Times Although The Database Is Used By Varying Organisational Levels? 2 Examples
- What Is An Attribute In Java?
- How About Links Of London?
- When You Create A New COM Component In Visual Basic, You Choose The Following Template?
- What Parts Of Wordpad?
- What Is Indexed File Organization?

New Comment - Comments are editable for 5 min.