空の () で宣言すると、後で必要な寸法で再調整できます
次のプロジェクトを作成して実行し、2 つのコマンド ボタンをクリックして、表示されたデータを確認します。
'1 form with
' 2 command buttons : name=Command1, name=Command2
' 1 label : name=Label1
Option Explicit
Private mintVal() As Integer
Private Sub Command1_Click()
Dim intIndex1 As Integer, intIndex2 As Integer, intIndex3 As Integer
ReDim mintVal(5, 3, 4) As Integer
For intIndex1 = 0 To UBound(mintVal, 1)
For intIndex2 = 0 To UBound(mintVal, 2)
For intIndex3 = 0 To UBound(mintVal, 3)
mintVal(intIndex1, intIndex2, intIndex3) = intIndex1 + intIndex2 + intIndex3
Next intIndex3
Next intIndex2
Next intIndex1
ShowVals3
End Sub
Private Sub Command2_Click()
Dim intIndex1 As Integer, intIndex2 As Integer
ReDim mintVal(3, 7) As Integer
For intIndex1 = 0 To UBound(mintVal, 1)
For intIndex2 = 0 To UBound(mintVal, 2)
mintVal(intIndex1, intIndex2) = intIndex1 * intIndex2
Next intIndex2
Next intIndex1
ShowVals2
End Sub
Private Sub Form_Resize()
Dim sngWidth As Integer, sngHeight As Single
Dim sngCmdWidth As Single, sngCmdHeight As Single
sngWidth = ScaleWidth
sngCmdHeight = 495
sngCmdWidth = sngWidth / 2
sngHeight = ScaleHeight - 495
Label1.Move 0, 0, sngWidth, sngHeight
Command1.Move 0, sngHeight, sngCmdWidth, sngCmdHeight
Command2.Move sngCmdWidth, sngHeight, sngCmdWidth, sngCmdHeight
End Sub
Private Sub ShowVals2()
Dim intIndex1 As Integer, intIndex2 As Integer
Dim strShow As String
strShow = ""
For intIndex1 = 0 To UBound(mintVal, 1)
strShow = strShow & CStr(mintVal(intIndex1, 0))
For intIndex2 = 1 To UBound(mintVal, 2)
strShow = strShow & "," & CStr(mintVal(intIndex1, intIndex2))
Next intIndex2
strShow = strShow & vbCrLf
Next intIndex1
Label1.Caption = strShow
End Sub
Private Sub ShowVals3()
Dim intIndex1 As Integer, intIndex2 As Integer, intIndex3 As Integer
Dim strShow As String
strShow = ""
For intIndex1 = 0 To UBound(mintVal, 1)
For intIndex2 = 0 To UBound(mintVal, 2)
strShow = strShow & CStr(mintVal(intIndex1, intIndex2, 0))
For intIndex3 = 1 To UBound(mintVal, 3)
strShow = strShow & "," & CStr(mintVal(intIndex1, intIndex2, intIndex3))
Next intIndex3
strShow = strShow & vbCrLf
Next intIndex2
strShow = strShow & vbCrLf
Next intIndex1
Label1.Caption = strShow
End Sub