Monday, November 8, 2010

Calling a Sub Procedure

Once you have a procedure, whether you created it or it is part of the Visual Basic language, you can use it. Using a procedure is also referred to as calling it.

Before calling a procedure, you should first locate the section of code in which you want to use it. To call a simple procedure, type its name. Here is an example:

Sub CreateCustomer()
Dim strFullName As String
strFullName = "Chidambaram Palaniappan"
End Sub

Sub Exercise()
CreateCustomer
End Sub

Besides using the name of a procedure to call it, you can also precede it with the Call keyword. Here is an example:

Sub CreateCustomer()
Dim strFullName As String
strFullName = "Chidambaram Palaniappan"
End Sub

Sub Exercise()
Call CreateCustomer
End Sub

When calling a procedure, without or without the Call keyword, you can optionally type an opening and a closing parentheses on the right side of its name. Here is an example:

Sub CreateCustomer()
Dim strFullName As String
strFullName = "Chidambaram Palaniappan"
End Sub

Sub Exercise()
CreateCustomer()
End Sub

No comments: