Skip to content

Instantly share code, notes, and snippets.

@dzzie
Created June 29, 2022 09:15
Show Gist options
  • Save dzzie/fd7ca09d25abd723dfe2bb51ed7f2679 to your computer and use it in GitHub Desktop.
Save dzzie/fd7ca09d25abd723dfe2bb51ed7f2679 to your computer and use it in GitHub Desktop.
Private Sub Form_Load()
Dim t As t1 'defined as public UDT in an activex dll
t.aaaaa = 21
t.bbbbb = "test"
t.ccccc = "blahblah"
Debug.Print UDTMemberGetValue(t, "bbbbb")
End Sub
'walk udt struct with tli
' Dim mi As MemberInfo, ri As RecordInfo
'
' For Each ri In tli.Records
' Debug.Print ri.Name
' For Each mi In ri.Members
' Debug.Print " " & mi.Name & " " & mi.ReturnType.VarType
' ‘more: https://github.com/dzzie/MAP/blob/61e600f83f857301d317f22d0caf55dd2737bcdb/tlbViewer/CTlbParse.cls#L120
' Next
' Next
'https://stackoverflow.com/questions/23797038/found-and-set-value-to-a-udt-member-vb6
Public Sub UDTMemberSetValue(ByRef pvUDTValue As Variant, _
ByVal psMemberName As String, _
ByRef pvMemberValue As Variant)
Dim oApp As TLI.TLIApplication
Dim vTemp As Variant
Set oApp = New TLI.TLIApplication
vTemp = CVar(pvUDTValue)
oApp.RecordField(vTemp, psMemberName) = pvMemberValue
pvUDTValue = vTemp
End Sub
Public Function UDTMemberGetValue(ByRef pvUDTValue As Variant, ByVal psMemberName As String)
Dim oApp As TLI.TLIApplication
Dim vTemp As Variant
Set oApp = New TLI.TLIApplication
vTemp = CVar(pvUDTValue)
UDTMemberGetValue = oApp.RecordField(vTemp, psMemberName)
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment