#2
xyxcc1772017-10-22 19:37
|
程序代码:
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim ctl1 As Control
Dim i As Integer = 4
Dim a(i) As String
For Each ctl1 In Me.Controls
If Mid(ctl1.Name, 1, 2) = "Bu" Then
For i = 1 To 4
a(i) = ctl1.Name
' i = i + 1
TextBox1.Text = TextBox1.Text & vbCrLf & "a" & i & "=" & a(i)
Next
End If
Next ctl1
End Sub
Dim ctl1 As Control
Dim i As Integer = 4
Dim a(i) As String
For Each ctl1 In Me.Controls
If Mid(ctl1.Name, 1, 2) = "Bu" Then
For i = 1 To 4
a(i) = ctl1.Name
' i = i + 1
TextBox1.Text = TextBox1.Text & vbCrLf & "a" & i & "=" & a(i)
Next
End If
Next ctl1
End Sub
我希望输出的结果是
a1=button1,
a2=button2,
a3=button3…
实际的输出结果是这个样子的,我不知道到底哪里出了问题,
我希望遍历集合,把符合条件的,一个一个的输出到一个数组里面,
只有本站会员才能查看附件,请 登录