如何更改循环中所有标签的值

How can I change the value of all Labels in a loop

我正在尝试将标签的值更改为数组中的某个值。我有一个循环遍历我的数组

我希望能够做这样的事情

标签 & i.text = "some text"

Dim QuestionArray(10) As String
'dr is OleDbDataReader from database
While dr.Read()
QuestionArray(cnt)=(dr("Question").ToString)
cnt+=1
End While

For i = 0 To QuestionArray.Length
'Label(i) can not be used
Label(i).text = QuestionArray(i)
Next i 

希望对你有帮助...

For Each objCtrl As Control In yourFormName.Controls
        ' Assign Some Text 
If TypeOf objCtrl Is Label Then
End If
Next

您可以创建一个数组来保存您的标签。

Dim LabelArray() As Label = {Label0, Label1, Label2, Label3, Label4, Label5, _
  Label6, Label7, Label8, Label9, Label10}
    For i = 0 To QuestionArray.Length - 1
        LabelArray(i).Text = QuestionArray(i)
    Next