'配列の次元を取得する関数 Option Explicit Type TVarData VType As Integer Reserved(0 To 2) As Integer VarArray As Long End Type Type TMyVariant Value As Variant End Type Declare Sub RtlMoveMemory Lib "kernel32.dll" ( _ ByRef Destination As Any, ByRef Source As Any, _ ByVal Length As Long) Function GetDimCount(array1 As Variant) As Integer Dim i As Long Dim a As TMyVariant Dim b As TVarData a.Value = array1 RtlMoveMemory b, a, 12 If (b.VType And &h2000) = 0 Then GetDimCount = 0 Else RtlMoveMemory i, ByVal b.VarArray, 2 GetDimCount = i End If End Function Sub Test1() Dim a(0 To 2, 0 To 2) As Integer MsgBox GetDimCount(a) End Sub