下面是一个判断动态数组是否为空,及是否被赋值过的样例程序。
Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (ByRef Ptr() As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any,ByRef Source As Any,ByVal Length As Long)Function Not_Null(MyArr() As Variant) As Long
Dim pMyarr As Long
CopyMemory pMyarr,ByVal VarPtrArray(MyArr),4
Not_Null = pMyarr
End Function
Sub test() Dim arr() As Variant If Not_Null(arr) <> 0 Then MsgBox "该数组不为空" Else MsgBox "该数组为空数组" End If End Sub