我想做一个 For Each 循环,我可以检查每个按钮是启用还是禁用。如果按钮已启用,那么我必须获取每个按钮的标签中的值。我有 26 个按钮,每个按钮都包含不同的值(现金奖励)。*重要提示:此代码需要位于按钮下方,因此每六次按下它就会检查按钮。
伪代码:
btncase1.tag = 5
Begin while statement to go through each button
Check each button to see if it is enabled
If button is enabled then obtain values
Next
我拥有的实际代码,但对我来说没有任何意义:
Public Class Form1
Dim button As Button
Dim totalremcases As Integer
Dim btncase As New Control
Dim btncollection As New Microsoft.VisualBasic.Collection()
Private Sub btncase1_Click()
For Each button As Button In btncollection
If btncase.Enabled Then
totalremcases = totalremcases + CInt(btncase.Tag)
End If
Next