Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default 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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default 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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to have Checkbox A uncheck with checked Checkbox B Texas Aggie Excel Discussion (Misc queries) 3 July 20th 07 10:58 PM
link a checkbox in a sheet to a checkbox on a userform? Arjan Excel Programming 0 November 10th 06 01:37 PM
How do I link one checkbox to update another checkbox? Mike Excel Programming 3 April 28th 06 02:22 AM
checkbox on form reset from checkbox on sheet raw[_12_] Excel Programming 1 December 3rd 05 05:08 AM
For each Checkbox teresa Excel Programming 4 February 4th 05 01:45 AM


All times are GMT +1. The time now is 08:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"