Gruppe
Dialog
Bereich
CheckBox
Thema
Anzahl von CheckBoxes in einer UserForm ermitteln
Problem
Wie kann ich ermitteln, wieviel CheckBoxes sich in einer UserForm befinden?
Lösung
Geben Sie den nachfolgenden Code in das Klassenmodul der UserForm ein.
ClassModule: frmCheckBoxWerte
Private Sub cmdWeiter_Click()
Unload Me
End Sub
Private Sub cmdCount_Click()
Dim cnt As Control
Dim iCount As Integer
For Each cnt In Controls
If TypeName(cnt) = "CheckBox" Then iCount = iCount + 1
Next cnt
MsgBox "Diese UserForm besitzt " & iCount & " CheckBoxes!"
End Sub
StandardModule: basMain
Sub CallForm()
frmCheckBoxWerte.Show
End Sub