Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Return value collection

Is there any way I can return a series of variables from a .dll file.
The number of variables in this array varies between 1 and 100.
In the class header, I cannot define an array, collection, or a type array to hold and return the values to the called exe file.
thanks.
[292 byte] By [rkbnair] at [2007-11-11 7:06:41]
# 1 Re: Return value collection
CTest.cls

Option Explicit
Public Function ReturnValues() As Integer()

' Returns Integer array with random number
' of elements, between 1 and 100

Dim nValues As Integer
nValues = Rnd(0) * 100 + 1

ReDim ReturnArray(1 To nValues) As Integer

Dim I As Integer
For I = 1 To nValues
ReturnArray(I) = I
Next

ReturnValues = ReturnArray

End Function

Client code:

Dim Values() As Integer
Dim clsTest As New CTest
Values = clsTest.ReturnValues()
Phil Weber at 2007-11-11 17:27:23 >
# 2 Re: Return value collection
Thank you Phil: it worked like a charm !
rkbnair at 2007-11-11 17:28:31 >