KingofKong
06-11-2009, 10:24 AM
Hello! I am trying to pass a member (element) of a UDT and running into difficulties. i can pass a UDT array, but im not able to specify which piece of the UDT i want the sub to focus on. im sure its in my declaration. im declaring it as a string which is probably the problem.
Type SpreadData
name As String
time As Date
l As Double
b As Double
a As Double
End Type
Public NIY(100) As SpreadData
Sub Start()
Dim i As Integer
Dim element As String
i = 0
NIY(i).name = "NIY"
NIY(i).time = Now
NIY(i).l = 10055
NIY(i).a = 10050
NIY(i).b = 10045
element = "b" 'element (type.member) needs to be dynamic between l, b, and a
Call f(NIY, num, element)
End Sub
Sub f(ByRef NIY() As SpreadData, i As Integer, element As String)
Worksheets("Sheet1").Rows(1).Columns("A") = NIY(i).&"part" 'the problem for me is passing the element
End Sub
Thank you so much for your help!
Happy coding
Type SpreadData
name As String
time As Date
l As Double
b As Double
a As Double
End Type
Public NIY(100) As SpreadData
Sub Start()
Dim i As Integer
Dim element As String
i = 0
NIY(i).name = "NIY"
NIY(i).time = Now
NIY(i).l = 10055
NIY(i).a = 10050
NIY(i).b = 10045
element = "b" 'element (type.member) needs to be dynamic between l, b, and a
Call f(NIY, num, element)
End Sub
Sub f(ByRef NIY() As SpreadData, i As Integer, element As String)
Worksheets("Sheet1").Rows(1).Columns("A") = NIY(i).&"part" 'the problem for me is passing the element
End Sub
Thank you so much for your help!
Happy coding