ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why Checkbox count = 4 (https://www.excelbanter.com/excel-programming/387192-re-why-checkbox-count-%3D-4-a.html)

Dave Peterson

Why Checkbox count = 4
 
How did you declare ckboxct?

Is it accumulating each time you run the procedure?

JMay wrote:

attempting to better understand the use of TypeOf I have created:
All message boxs return the proper number, except the CkBoxct,
which returns 4, when IN FACT there is only 1 Checkbox on my Userform1.
Any ideas why this problem?
TIA,
Jim May

Private Sub CommandButton1_Click()
For Each ctl In UserForm1.Controls
If TypeOf ctl Is MSForms.Label Then labelct = labelct + 1
If TypeOf ctl Is MSForms.Frame Then Framect = Framect + 1
If TypeOf ctl Is MSForms.CheckBox Then CkBoxct = CkBoxct + 1
If TypeOf ctl Is MSForms.TextBox Then Txtct = Txtct + 1
If TypeOf ctl Is MSForms.OptionButton Then OptBnct = OptBnct + 1
If TypeOf ctl Is MSForms.ComboBox Then ComBoxct = ComBoxct + 1
Next ctl
MsgBox "labels total " & labelct
MsgBox "Frame total " & Framect
MsgBox "Checkboxes total " & CkBoxct
MsgBox "Textboxs total " & Txtct
MsgBox "OptionButtons total " & OptBnct
MsgBox "ComboBoxs total " & ComBoxct
End Sub


--

Dave Peterson


All times are GMT +1. The time now is 07:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com