樓上回答的什么啊,
創(chuàng)新互聯(lián)公司成立于2013年,是專業(yè)互聯(lián)網(wǎng)技術服務公司,擁有項目網(wǎng)站設計、成都網(wǎng)站設計網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元南崗做網(wǎng)站,已為上家服務,為南崗各地企業(yè)和個人服務,聯(lián)系電話:18982081108
真是看不下去,
簡單問題復雜了
舉個例子:二維數(shù)組賦值
Dim i1, i2
Dim a(10, 10)
For i1 = 0 To 10
For i2 = 0 To 10
a(i1, i2) = i2
Next
Next
數(shù)組賦值是指針傳遞,如果想復制數(shù)組就要用一個循環(huán)遍歷所有元素并賦值.這樣改變其中一個數(shù)組的值才不會影響到另外一個數(shù)組.
我剛打開寫了一下,基本就是你這樣的,嵌套一層大括號一維,看著啊
Dim a(,,) As Integer = New Integer(,,) {{{11, 12, 13}, {21, 22, 23}, {31, 32, 33}}, {{41, 42, 43}, {51, 52, 53}, {61, 62, 63}}, {{71, 72, 73}, {81, 82, 83}, {91, 92, 93}}}
不能直接賦值
如果要給多維數(shù)組賦值的話,可以變通一下
Dim x As Integer
Private Sub Command1_Click()
Dim b As Variant
Dim a(3, 3)
b = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
For i = 0 To 2
For j = 0 To 2
a(i, j) = b(x)
x = x + 1
Print a(i, j)
Next j
Next i
End Sub
僅供參考
Dim xlsApp As Excel.Application
Dim xlsBook As Excel.Workbook
Private Sub Command1_Click()
Dim I, J As Integer
Dim A(500, 2)
Set xlsApp = Excel.Application
xlsApp.Visible = False
'假設Excel文件在:D:\Book1.xls
Set xlsBook = xlsApp.Workbooks.Open("D:\Book1.xls")
For I = 1 To 500
For J = 1 To 2
A(I - 1, J - 1) = xlsapp.cells(I, J)
Next J
Next I
'以下是退出Excel
xlsBook.Close (False)
xlsApp.Quit
Set xlsApp = Nothing
'=================================
'Excel中的500×2的數(shù)據(jù)已讀入到數(shù)組A()中,以下可以添加你要運算的代碼。
'=================================
End Sub
Dim abc(2) As Integer
abc = {0, 1, 2}
'或者
Dim abcd() As Integer
ReDim abcd(9)
For i As Integer = 0 To abcd.Length - 1
abcd(i) = i
Next
也可聲明為字符串數(shù)組