
正文
数组的维度vb.net 数组的维度和定义教案
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net如何定义一维和多维数组
用一个带括号的变量名来定义一维数组和多维数组如dim a(5) as integer '定义了1个1维、6个元素数组dim a(5,5) as integer '定义了1个2维、36个元素的数组
相关问答
Q1: VB.net中如何求出2维数组,每个维度上的值得个数
每行的数字个数不同,你说的这是不规则数组,解决方案如下:
Dim b As String = ""
Dim a As Integer()() = New Integer(9)() {}
a(0) = New Integer() {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
a(1) = New Integer() {0, 3, 4, 5}
a(2) = New Integer() {0, 4, 5, 6, 7}
a(3) = New Integer() {0, 6, 5, 8, 9, 1}
a(4) = New Integer() {0, 2, 5, 1, 7}
a(5) = New Integer() {0, 4, 2, 6, 7, 3}
a(6) = New Integer() {0, 4, 5, 3, 2}
a(7) = New Integer() {0, 4, 1, 6, 2, 8, 5, 3}
a(8) = New Integer() {0, 4, 9, 6, 3, 5, 7}
a(9) = New Integer() {0, 1, 5, 9, 7, 6, 2, 4, 3, 8}
For i As Integer = 0 To a.GetUpperBound(0)
b = "第" i + 1 "行有" a(i).GetUpperBound(0) + 1 "个数" vbCrLf
Next
MessageBox.Show(b)
Q2: vb.net 多维数组怎么表示
array(2,2)是多维数组的访问方式,其数组的定义和初始化方法为:
Dim array As Integer(,) = {{1, 2, 3}, {4, 5, 6}}
每一行的元素数量是固定且相等的。
array(2)(2)是交错数组(即数组的数组)的访问方式。也就是,你有一个数组,这个数组的每个元素也是数组。其数组的定义和初始化方法为:
Dim array As Integer()() = {New Integer() {1, 2, 3}, New Integer() {4, 5, 6, 7, 8}}
由于每个元素是独立的数组,所以交错数组每一行的元素数量不固定,且可以不等。
Q3: vb.net 数组怎么自动定义维数
动态数组一般开始不能直接写dim a as string。除非Variant。一般先定义类型 但是数组名后得加上括号。例如
DIM a() AS STRING
后面根据需要使用的时候,可以自己定义大小。但是必须注意一点。重新定义的时候,
Redim a(11) 的时候,就会将原来的数组元素清空了,没有保存。
Redim Preserve a(11) 就会将重新定义数组大小的同时,还将原来的数据保存了。
数组的维度vb.net的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于数组的维度和定义教案、数组的维度vb.net的信息别忘了在本站进行查找喔。






