Re: Why Checkbox count = 4
- From: JMay <JMay@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 11 Apr 2007 09:44:04 -0700
Thanks Tom:
Your code produces in my immediate window:
1 OptionButton1
2 OptionButton2
3 CheckBox1
And my Msgbox for Checkboxes indicates 3;
But there is ONLY 1 !!
"Tom Ogilvy" wrote:
Add a debugging statement.
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
debug.print CkBoxct, ctl.name
end if
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
See the results in the immediate window in the VBE (view=>Immediate window
if it isn't already visible)
--
Regards,
Tom Ogilvy
"JMay" wrote:
JE,
When I (in the immediate window) enter your suggested
?UserForm1.Controls.Count
I get the right total count -- But still a Checkbox Overcount;
I'm still working on.. I'll report back if I CRACK..
No Checkboxes ARE HIDDEN
Tks,
Jim
"JE McGimpsey" wrote:
At the risk of offending, are you sure that there aren't checkboxes
hidden by other controls (perhaps frame(s)?)?
If you execute
?UserForm1.Controls.Count
in the immediate window, do you get the correct total?
In article <9049AF53-701F-4AA1-B39E-FCD6301D866E@xxxxxxxxxxxxx>,
JMay <JMay@xxxxxxxxxxxxxxxxxxxxxxxxx> 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
- Follow-Ups:
- Re: Why Checkbox count = 4
- From: JMay
- Re: Why Checkbox count = 4
- References:
- Re: Why Checkbox count = 4
- From: JE McGimpsey
- Re: Why Checkbox count = 4
- From: Tom Ogilvy
- Re: Why Checkbox count = 4
- Prev by Date: Re: Subtraction by row
- Next by Date: Add values from two columns into third one in another worksheet
- Previous by thread: Re: Why Checkbox count = 4
- Next by thread: Re: Why Checkbox count = 4
- Index(es):
Relevant Pages
|