How to return an array from a function

Parent Form Function that passes back an Array / Vector

 Private Sub ReceiveArray_Click()
    Dim intRcvArray() As Integer
    Dim i As Integer

    UserInterface.Text = ""
    intRcvArray = NumberList()                   ‘ —Get the array of strings.
    For i = LBound(intRcvArray) To UBound(intRcvArray)     ‘ —Display the strings.
       UserInterface.Text = UserInterface.Text & CStr(i) & " "
    Next i

End Sub

Private Function NumberList() As Integer()          ‘ — This function returns an array 
  Dim intArray() As Integer
  Dim i As Integer

    ReDim intArray(1 To 10)
    For i = 1 To 10
        intArray(i) = i             
    Next i

    NumberList = intArray
End Function


Code here:

Categories: CodingVisual-Basic


Leave a Reply

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