是否可以用整数标记Label?
Dim nr As Integer = 1
Do
Label(nr).text = "something"
nr += 1
Loop until nr = 4
然后它会填满标签
编辑: 我想知道是否可以创建Label数组。 我发现this篇文章将我自己的方法放在一起。
label1.Text = "test1"
label2.Text = "test2"
label1.Location = New Point(120, 80)
label2.Location = New Point(140, 20)
Me.Controls.Add(label1)
Me.Controls.Add(label2)
Dim labels() As Label = {label1, label2}
For Each label As Label In labels
label.Text = "new test"
Next
答案 0 :(得分:3)
您可以在显示标签的表单的控件集合中使用标签名称。
For i as integer = 0 to 49 Step 1
Me.Controls("Label" & i.toString).Text = "Something"
Next
答案 1 :(得分:0)
这样的事可能吗?
Dim lbl As Label() = New Label(9) {}
Dim nr As Integer = 0
Do
lbl(nr) = New Label()
lbl(nr).Text = "somthing " & nr
nr += 1
Loop While nr <> 4