Array from function or method question

minoad

New member
Joined
Mar 5, 2006
Messages
2
Programming Experience
1-3
Any tips on returning an array from a function if i have no idea how many elements will be in it.
My questions are:
1) what type does my function return? (note first question marks)
2) what is the syntax of my 'Return' statement? (note second question marks)
3) how do i declare my variable from the caller (note third question marks)
4) how do i actually set my variable equal to my function (note fourth question marks)

I am sorry for the elementary nature of the question, however i am having one heck of a time.

Thanks

For Example:

Function ReturnArray() as ???

dim arrTest(5) as string
arrTest(0) = "Blah"
arrTest(1) = "Blah"
arrTest(2) = "Blah"
arrTest(3) = "Blah"
arrTest(4) = "Blah"
arrTest(5) = "Blah"

Return arrTest() ???

End Function

dim test as ???

test??? = returnArray()
 
Use This to return a value form array
VB.NET:
 function ReturnArray() as string
    dim arrTest(5) as string
    arrTest(0)="B"
    arrTest(1)="B"
    arrTest(2)="B"
    arrTest(3)="B"
    arrTest(4)="B"
    arrTest(5)="B"

    return arrTest(<array index>)
 end function

 dim test as string
 test=returnArray()
 
This for return all arry:
VB.NET:
 Function ReturnArray() As String()
        Dim arrTest(5) As String
        arrTest(0) = "B"
        arrTest(1) = "B"
        arrTest(2) = "B"
        arrTest(3) = "B"
        arrTest(4) = "B"
        arrTest(5) = "B"

        Return arrTest
    End Function

    Dim t() As String
    t = ReturnArray()
 
Back
Top