The code below works to the point MsgBox v.
Using watch I can see the data in the TD() and then data() in the function. Msgbox displays but contains nothing.
My goal is to fill or modify TD by passing to a function. Again using watch I can see the data in each variable. However I donot see the modified data in Main
Thank You
Marlin
REM ***** BASIC *****
'Test passing Used defined Data types to functions
Public Type TestData
D1 as Long
D2 as String
End Type
Sub Main
Dim TD(5) As New TestData
Dim i, j As Integer
Dim s as String
Dim v as Variant
j = 4
For i = 0 to j
TD(i).D1 = i
TD(i).D2 = Chr(134 + j * 2) & " More Data " & j^3
s = s + "TD(" & i & ")= " & TD(i).D1 & Chr(13) & _
"TD(" & i & ")= " & TD(i).D2 & Chr(13)
Next i
MsgBox s
v = SetTestData(TD())
MsgBox v
End Sub
Function SetTestData( data as Variant) as Variant
Dim i As Integer
For i = LBound(data) to UBound(data)
data(i).D1 = i^2
data(i).D2 = Chr(217 + j) & " Addtional Data " & j^3
Next i
SetTestData = data()
End Function
[erAck: edited to format code as code … see This is the guide - How to use the Ask site? - #6 by erAck ]