※ 引述《darien ( 毛茸茸)》之銘言:
: 我定義了三個2x2陣列
: Dim A(1,1), B(1,1), C(1,1) As Integer
: 然後個別填入A和B各元素(element)的值
: 接著我想做 C = A - B
: 但為什麼程式告訴我這個敘述是違法的?
: A = 1 0
: 0 1
: B = 2 3
: 0 2
: 我只是單純想得到 C = -1 -3
: 0 -1 而已呀@@?
: 難道陣列的運算需要別的敘述語法?
就一個一個減
Dim A(1, 1) As Integer, B(1, 1) As Integer, C(1, 1) As Integer
Dim i As Integer
Dim j As Integer
A(0, 0) = 1
A(0, 1) = 0
A(1, 0) = 0
A(1, 1) = 1
B(0, 0) = 2
B(0, 1) = 3
B(1, 0) = 0
B(1, 1) = 2
For i = LBound(C) To UBound(C)
For j = LBound(C, 2) To UBound(C, 2)
C(i, j) = A(i, j) - B(i, j)
Debug.Print C(i, j)
Next j
Next i