DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Feb 2013

    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.
        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
                    ctl.Visible = False
                End If
            End If
    (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?

    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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.