If you arrange your UDT such that like types are together you could use CopyMemory and a loop to check the values. (Althoough I think you end up typing more characters than you would if you'd performed 10 case statements). It only works for types that are fixed length excepting Strings. (It just doesn't work for string variables)
eg
Code:Private Type TEST_TYPE aLong1 As Long aLong2 As Long aLong3 As Long anInteger1 As Integer anInteger2 As Integer anInteger3 As Integer End Type Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (Destination As Any, _ Source As Any, _ ByVal Length As Long) Private udtReal As TEST_TYPE Private lngUDTLongs(2) As Long Private intUDTIntegers(2) As Integer Private Sub Command1_Click() Dim intI As Integer ' ' Set-up some values in the udt ' udtReal.anInteger1 = 10 udtReal.anInteger2 = 12 udtReal.aLong2 = 123456 ' ' Copy the Integer values to the integer array ' and display their values ' CopyMemory intUDTIntegers(0), udtReal.anInteger1, 6 For intI = 0 To 2 Debug.Print intUDTIntegers(intI) Next intI ' ' Do the same for the Longs ' CopyMemory lngUDTLongs(0), udtReal.aLong1, 12 For intI = 0 To 2 Debug.Print lngUDTLongs(intI) Next intI End Sub




Reply With Quote