大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
楼上回答的什么啊,
创新互联公司成立于2013年,是专业互联网技术服务公司,拥有项目网站设计、成都网站设计网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元南岗做网站,已为上家服务,为南岗各地企业和个人服务,联系电话:18982081108
真是看不下去,
简单问题复杂了
举个例子:二维数组赋值
Dim i1, i2
Dim a(10, 10)
For i1 = 0 To 10
For i2 = 0 To 10
a(i1, i2) = i2
Next
Next
数组赋值是指针传递,如果想复制数组就要用一个循环遍历所有元素并赋值.这样改变其中一个数组的值才不会影响到另外一个数组.
我刚打开写了一下,基本就是你这样的,嵌套一层大括号一维,看着啊
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}}}
不能直接赋值
如果要给多维数组赋值的话,可以变通一下
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的数据已读入到数组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
也可声明为字符串数组