Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, source As Any, ByVal Length As Long)
Private Const VT_BYREF = &H4000&
Private Sub Command1_Click()
Dim S(6, 12, 24, 36, 48) As Single
MsgBox Dimensions(S)
End Sub
Function Dimensions(ByRef MYARRAY) As Integer
Dim VTYPE As Integer, LP As Long
CopyMemory VTYPE, MYARRAY, 2
CopyMemory LP, ByVal VarPtr(MYARRAY) + 8, 4
If (VTYPE And VT_BYREF) Then CopyMemory LP, ByVal LP, 4
CopyMemory Dimensions, ByVal LP, 16
End Function
返回 5