比如有2个结构体
private type TestA
s1 as string
end typeprivate type TestB
s2 as string
end typedim a as TestA
dim b as TestB
然后怎么定义一个数组后把a,b放到数组中去
再for循环拿出来,并打印里面的s1和s2内容?我碰到了报错信息“只有定义在公共对象模块中用户定义类型能和变体类型...”这是我的一个作业,要求必须使用结构体,还不能用类。谢谢指教!
private type TestA
s1 as string
end typeprivate type TestB
s2 as string
end typedim a as TestA
dim b as TestB
然后怎么定义一个数组后把a,b放到数组中去
再for循环拿出来,并打印里面的s1和s2内容?我碰到了报错信息“只有定义在公共对象模块中用户定义类型能和变体类型...”这是我的一个作业,要求必须使用结构体,还不能用类。谢谢指教!
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
Private Type TestA
s1 As String
End TypePrivate Type TestB
s2 As String
End TypeDim a As TestA
Dim b As TestBDim c(1) As LongPrivate Sub Command1_Click()
Dim i As Long
Dim s As String
For i = 0 To UBound(c)
CopyMemory ByVal VarPtr(s), ByVal c(i), 4
MsgBox s
NextEnd SubPrivate Sub Form_Load()
a.s1 = "hello"
b.s2 = "test"
c(0) = VarPtr(a)
c(1) = VarPtr(b)
End Sub
Private Type TestA
s1 As String
r1 As Integer
End Type那么怎么样将s1和r1都取出来?
刚才自己试验了加了一下,没读取出来