View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_3_] Alan Beban[_3_] is offline
external usenet poster
 
Posts: 130
Default Passing arrays to a subroutine

As does this:

Public Sub arrayPass()
Dim argArray(3) As Integer

argArray(0) = 12
argArray(1) = 13
MsgBox testerSub(argArray)

End Sub


Public Function testerSub(inputArray As Variant)
Dim test1 As Integer, test2 As Integer

test1 = inputArray(0)
test2 = inputArray(1)
testerSub = test1 & " " & test2

End Function

Alan Beban

Rob Bovey wrote:
Hi Braden,

This works for me:

Public Sub arrayPass()
Dim argArray(3) As Integer
argArray(0) = 12
argArray(1) = 13
testerSub argArray
End Sub

Public Sub testerSub(argArray() As Integer)
Dim test1 As Integer
Dim test2 As Integer
test1 = argArray(0)
test2 = argArray(1)
Debug.Print test1, test2
End Sub