Article ID: 116140
Article Last Modified on 1/19/2007
Function YourFunctionName (InArray() As String) As Integer Sub YourSubName (InArray() As String)The following example demonstrates the correct syntax for procedure calls with an array:
Result = YourFunctionName(YourArrayName()) YourSubName YourArrayName()NOTE: When calling procedures in Visual Basic, you do not have to include the opening and closing parentheses after "YourArrayName" in the above example.
'---------------------------------------------------------------
'GLOBAL DECLARATIONS SECTION
'---------------------------------------------------------------
Option Explicit
'---------------------------------------------------------------
'The function LoadArray() loads an array called MyArray
'with string values. After loading the array, the function
'calls a procedure that displays each array element
'in a message box.
'---------------------------------------------------------------
Function LoadArray()
Dim i as Integer
ReDim MyArray(10) As String
For i = 1 to 10
MyArray(i) = "Test Value: " & i
Next i
DisplayArray MyArray()
End Function
'---------------------------------------------------------------
'LoadArray() Sub Procedure
'---------------------------------------------------------------
Sub DisplayArray (InArray() As String)
Dim i as Integer
For i = 1 to UBound(InArray)
MsgBox InArray(i)
Next i
End Sub
? LoadArray()
Keywords: kbhowto kbprogramming KB116140