計算窗體複選框控件爲真的個數

Private Sub Command6_Click()
Dim Ctl As Control
Dim intCount As Integer

For Each Ctl In Me.Controls
If Ctl.ControlType = acCheckBox Then
If Ctl = True Then
intCount = intCount + 1
End If
End If
Next

 

If intCount > 1 Then
MsgBox "你不能選擇多於一個選項!"
ElseIf intCount = 0 Then

MsgBox "你不能不選擇一個選項!"
ElseIf intCount = 1 Then

MsgBox "你選擇正確!"

 

End If

End Sub

發佈了30 篇原創文章 · 獲贊 5 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章