vb.net编程,怎么把图片里的button按钮用循环写出来
1个回答
展开全部
Public Class Form1
Public MyButtons(4) As Button
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim bt As Control
For Each bt In Me.Controls
Select Case bt.Name
Case "Button1"
MyButtons(1) = bt
Case "Button2"
MyButtons(2) = bt
Case "Button3"
MyButtons(3) = bt
Case "Button4"
MyButtons(4) = bt
End Select
Next
Dim i As Integer
For i = 1 To 4
MsgBox(MyButtons(i).Name)
Next
End Sub
End Class
Public MyButtons(4) As Button
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim bt As Control
For Each bt In Me.Controls
Select Case bt.Name
Case "Button1"
MyButtons(1) = bt
Case "Button2"
MyButtons(2) = bt
Case "Button3"
MyButtons(3) = bt
Case "Button4"
MyButtons(4) = bt
End Select
Next
Dim i As Integer
For i = 1 To 4
MsgBox(MyButtons(i).Name)
Next
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询