Why Checkbox count = 4
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 , 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 |
Why Checkbox count = 4
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 , 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 |
Why Checkbox count = 4
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 , 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 |
Why Checkbox count = 4
My ONLY two OptionButtons ARE INSIDE my Frame Control
With my Userform active, when I click on the Properties Drop-down I do not see my 2 optionbuttons,,, hummmmmmm -- these are being counted as a checkbox (no doubt) .... hummmm "JMay" wrote: 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 , 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 |
Why Checkbox count = 4
I affirm your experience. I put 2 OptionButtons in a Frame and they
were miscounted as CheckBoxes. However, using the following gave the correct count. For Each ctl In UserForm1.Controls If TypeName(ctl) = "CheckBox" Then CkBoxct = CkBoxct + 1 Next ctl Hth, Merjet |
Why Checkbox count = 4
Yeah, The following works fine -- WITHOUT A PROBLEM
Thanks for your input.. Private Sub CommandButton2_Click() For Each ctl In UserForm1.Controls If TypeName(ctl) = "Label" Then labelct = labelct + 1 If TypeName(ctl) = "Frame" Then Framect = Framect + 1 If TypeName(ctl) = "CheckBox" Then CkBoxct = CkBoxct + 1 'Debug.Print CkBoxct, ctl.Name End If If TypeName(ctl) = "TextBox" Then Txtct = Txtct + 1 If TypeName(ctl) = "OptionButton" Then OptBnct = OptBnct + 1 If TypeName(ctl) = "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 "merjet" wrote: I affirm your experience. I put 2 OptionButtons in a Frame and they were miscounted as CheckBoxes. However, using the following gave the correct count. For Each ctl In UserForm1.Controls If TypeName(ctl) = "CheckBox" Then CkBoxct = CkBoxct + 1 Next ctl Hth, Merjet |
Why Checkbox count = 4
I deleted 1 of the original 3 optionbuttons I had at the time
I typed in the Subject line "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 , 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 |
All times are GMT +1. The time now is 02:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com