vb.net 数组赋值问题

2024-11-15 15:25:34
推荐回答(3个)
回答1:

vb.net已经去掉了控件数组这个类,不过有个代替该方式的一个属性:tag,你可以把这些关联的tag属性设置为同一标记,如:a。然后遍历所有的checkbox并且tag为a的则选定:
protected
sub
chkall_click()

for
each
ctl
as
control
in
me.controls
''如果checkbox在一个容器里,比如groupbox,那可以用groupbox.controls

if
ctl.gettype().name.tolower()
=
"checkbox"
then

ctype(ctl,
checkbox).checked
=
checkbox3.checked

end
if

next
end
sub

回答2:

我刚打开写了一下,基本就是你这样的,嵌套一层
大括号
一维,看着啊
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}}}

回答3:

方法一:
Dim x(,) As Integer
Dim i As Integer
ReDim x(0, 8)
For i = 0 To 8
x(0, i) = i \ 3
Next

方法二:
Dim x(,) As Integer
Dim i As Integer
For i = 0 To 8
ReDim Preserve x(0, i)
x(0, i) = i \ 3
Next