運作代碼:
Dim myarray(1 To 5, 1 To 5) As Long
Private Sub Command1_Click()
Print " 轉換前的矩陣"
For intx = 1 To 5
For inty = 1 To 5
myarray(intx, inty) = intx * 10 + inty
Next
Next
Print myarray(intx, inty),
Next inty
Next intx
Print vbCrLf
End Sub
Private Sub Command2_Click()
Print " 轉換後的矩陣"
For inty = intx To 5 '每次交換隻能從intx開始,不然重複交換,就和原來的一樣了。
temp = myarray(intx, inty)
myarray(intx, inty) = myarray(inty, intx)
myarray(inty, intx) = temp
學習總結:
1、每次交換隻能從行坐标intx開始,不然重複交換,就和原來的一樣了。