Mega Code Archive

 
Categories / VisualBasic Script / Language Basics
 

Passing Arrays as Parameters

Sub PassArray()     'Declare a six-element array     Dim astrNames(5) As String     Dim intCounter As Integer     'Call the FillNames function, passing a reference     'to the array     Call FillNames(astrNames)     'Use a For...Next loop to loop through the     'elements of the array     For intCounter = 0 To UBound(astrNames)         Debug.Print astrNames(intCounter)     Next intCounter End Sub Sub FillNames(varNameList As Variant)     'Populate the elements of the array     varNameList(0) = "A"     varNameList(1) = "B"     varNameList(2) = "C"     varNameList(3) = "D"     varNameList(4) = "E"     varNameList(5) = "F" End Sub