如下程式碼,供您參考(從編輯器中直接複製過來的,不知道為啥已經發出來同有格式了):
Sub TwoArrToOneArr()
Dim i As Integer "二維陣列的第一個變數
Dim j As Integer "二維陣列的第二個變數
Dim n As Integer "一維陣列的變更
Dim A(8, 8) As Integer "定義二維陣列
Dim B(64) As Integer "定義一維陣列
n = 0 "初始化n值
For i = 0 To 7
For j = 0 To 7
A(i, j) = 8 "初始化二維陣列
B(n) = A(i, j) "將二維陣列的值賦值給一維陣列
n = n + 1
Debug.Print B(n)
Next j
Next i
End Sub
如下程式碼,供您參考(從編輯器中直接複製過來的,不知道為啥已經發出來同有格式了):
Sub TwoArrToOneArr()
Dim i As Integer "二維陣列的第一個變數
Dim j As Integer "二維陣列的第二個變數
Dim n As Integer "一維陣列的變更
Dim A(8, 8) As Integer "定義二維陣列
Dim B(64) As Integer "定義一維陣列
n = 0 "初始化n值
For i = 0 To 7
For j = 0 To 7
A(i, j) = 8 "初始化二維陣列
B(n) = A(i, j) "將二維陣列的值賦值給一維陣列
n = n + 1
Debug.Print B(n)
Next j
Next i
End Sub