7,763
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Type SAFEARRAY1D
cDims As Integer
fFeatures As Integer
cbElements As Long
cLocks As Long
pvData As Long
cElements As Long
lLbound As Long
End Type
Sub Main()
Test
End Sub
Sub Test()
ReDim a(8) As String
ReDim b(8) As Integer
Dim c(8) As Integer
Dim d(8) As Variant
PrintSA "变长String", StrSAPtr(a)
PrintSA "变长Integer", SAPtr(b)
PrintSA "定长Integer", SAPtr(c)
PrintSA "定长Variant", SAPtr(d)
End Sub
Sub PrintSA(ByVal memo As String, ByVal ptr As Long)
Dim tSA As SAFEARRAY1D
CopyMemory tSA, ByVal ptr, Len(tSA)
Debug.Print memo, "&H" & Hex(tSA.fFeatures), tSA.fFeatures
End Sub
变长String &H180 384
变长Integer &H80 128
定长Integer &H92 146
定长Variant &H892 2194