CheckBoxes vs. OptionButtons in VBA


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: CheckBoxes vs. OptionButtons in VBA

Threaded View

  1. #1
    Join Date
    Feb 2013
    Posts
    5

    CheckBoxes vs. OptionButtons in VBA

    I have a UserForm in Excel with 100 checkboxes. At runtime, depending on which CommandButton a user clicks on, I get the contents of a particular column on one of 3 sheets and use those values for the Caption property of some (or all) of the CheckBoxes and hide the rest. My problem is that I also have 2 OptionButtons on the form, and my code for finding the Checkboxes and setting the Captions is not distinguishing between them and the CheckBoxes.
    Code:
        Dim i As Integer
        For Each ctl In Me.Controls
            If TypeOf ctl Is MSForms.CheckBox Then
                If i < intNumChoices Then
                    ctl.Caption = astrChoices(i)
                    ctl.Visible = True
                    i = i + 1
                Else
                    ctl.Visible = False
                End If
            End If
        Next
    (Please, no comments about the Hungarian notation. I still prefer it! :-)

    When I run this, the first two values in astrChoices() are put on the OptionButtons. How do I distinguish between the two different types of controls?

    Thanks.
    Last edited by Hack; 02-20-2013 at 02:46 PM. Reason: Added code tags

Similar Threads

  1. get the value of checkboxes
    By smithsf22 in forum ASP.NET
    Replies: 1
    Last Post: 04-22-2004, 10:52 PM
  2. Access grouped optionbuttons by index
    By Jürgen Schoch in forum VB Classic
    Replies: 2
    Last Post: 11-20-2002, 02:00 PM
  3. checkboxes
    By Brian Pittman in forum ASP.NET
    Replies: 2
    Last Post: 10-19-2001, 08:21 AM
  4. Checkboxes
    By Matt Wyant in forum VB Classic
    Replies: 1
    Last Post: 10-22-2000, 09:35 AM
  5. CheckBoxes
    By Chris in forum VB Classic
    Replies: 2
    Last Post: 07-18-2000, 06:04 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center