我想做一個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
這是你正在使用的代碼,你只是不理解而已你想解釋還是有特定的錯誤?所有按鈕都添加到btnCollection中了嗎? – Kyra