Sub Definition
Syntax:
[ | Private | Public | Friend ] Sub name[([param[, ...]])]
statements
End Sub
Group:Declaration
Description:
User defined subroutine. The subroutine defines a set of statements to be executed when it is called. The values of the calling arglist are assigned to the params. A subroutine does not return a result.
Sub defaults to Public if Private, Public or Friend are not is specified.
See Also:Declare, Function, Property.
Example:
Sub IdentityArray(A()) ' A() is an array of numbers
For I = LBound(A) To UBound(A)
A(I) = I
Next I
End Sub
Sub CalcArray(A(),B,C) ' A() is an array of numbers
For I = LBound(A) To UBound(A)
A(I) = A(I)*B+C
Next I
End Sub
Sub ShowArray(A()) ' A() is an array of numbers
For I = LBound(A) To UBound(A)
Debug.Print "(";I;")=";A(I)
Next I
End Sub
Sub Main
Dim X(1 To 4)
IdentityArray X() ' X(1)=1, X(2)=2, X(3)=3, X(4)=4
CalcArray X(),2,3 ' X(1)=5, X(2)=7, X(3)=9, X(4)=11
ShowArray X() ' print X(1), X(2), X(3), X(4)
End Sub