SafeArrayGetDim的错误写法:
Private Declare Function SafeArrayGetDim Lib "oleaut32" Alias "#17" (ByRef psa() As Any) As Long
'Private Declare Function SafeArrayGetDim Lib "oleaut32.dll" Alias "#17" (ByVal pas As Long) As Long
Private Sub Command1_Click()
Dim arr(2, 3, 4, 5) As Long
Debug.Print SafeArrayGetDim(arr)
End Sub
运行结果:
61880
SafeArrayGetDim的正确写法:
'Private Declare Function SafeArrayGetDim Lib "oleaut32" Alias "#17" (ByRef psa() As Any) As Long
Private Declare Function SafeArrayGetDim Lib "oleaut32.dll" Alias "#17" (ByVal pas As Long) As Long
Private Sub Command1_Click()
Dim arr(2, 3, 4, 5) As Long
Debug.Print SafeArrayGetDim(Not Not arr)
End Sub
运行结果:
4
注意上方Declare是不同的。