This routine will pass a parameter to another routine This routine receives the call with array as parameter


Sub TestPassArray()

  Dim LongArray(1 To 5) As Long
  Dim i As Integer
  For i = 1 To 5
    LongArray(i) = i
  Next i
  UserDisplay.Text = CStr(PassTest(LongArray()))

End Sub                                                                                                      


Function PassTest(ByRef LongPass() As Long) As Long

  Dim i  As Integer
  Dim Sum As Long
  For i = 1 To 5
     Sum = Sum + LongPass(i)
  Next i
PassTest = Sum
End Function




  1. The passing routine packs   1,2,3,4,5 into an array.
  2. The called routine calculates the sum of all the values in the array and passes the result back to the calling routine.
Categories: CodingVisual-Basic


Leave a Reply

Your email address will not be published. Required fields are marked *