Results 1 to 8 of 8

Thread: Setting option buttons to false

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    176

    Setting option buttons to false

    I have a form with two option buttons. I attempt to set them both to false in the load event. However the first one is always true when the form loads. When these same two options buttons are set to false later in the code they both go false as intended. These are the only option buttons on the form.

    If they both go false later in the program, why won't they do that in the load event?

  2. #2
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Setting option buttons to false

    can we see your code ? (the load event one). You can also set them to false in the designer.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,274

    Re: Setting option buttons to false

    Presumably you mean RadioButtons. It's a good idea to use the correct names for things to avoid confusion.

    The issue is that one of your RadioButtons is the first control in the Tab order. The first selectable control in the Tab order always gets focused by default when the form loads and a a RadioButton gets checked when it receives focus.

    If you wanted to use code to uncheck that RadioButton then you would have to do it in the Shown event handler, not the Load event handler. Alternatively, change the Tab order so that RadioButton is not first.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    176

    Re: Setting option buttons to false

    Quote Originally Posted by jmcilhinney View Post
    Presumably you mean RadioButtons. It's a good idea to use the correct names for things to avoid confusion.

    The issue is that one of your RadioButtons is the first control in the Tab order. The first selectable control in the Tab order always gets focused by default when the form loads and a a RadioButton gets checked when it receives focus.

    If you wanted to use code to uncheck that RadioButton then you would have to do it in the Shown event handler, not the Load event handler. Alternatively, change the Tab order so that RadioButton is not first.
    Yes I meant Radio Buttons. I learned VB on VB 6 and still use some of the terms I originally learned.

    Thanks that did it. Did not think of the tab order. Sometimes the simplest things!

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,943

    Re: Setting option buttons to false

    It was RadioButtons back then, too. The term is ancient!! Nobody has REAL radio buttons (buttons like that on their radio) anymore, though some of us did back in the day. Option Buttons is a far better name, in my opinion, so if you encountered that, you probably encountered it from somebody who shared my opinion.
    My usual boring signature: Nothing

  6. #6
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,106

    Re: Setting option buttons to false

    Quote Originally Posted by Shaggy Hiker View Post
    It was RadioButtons back then, too.
    In VB 6.0 IDE
    ToolTip says "OptionButton"
    Default name is "Option1"
    Default caption is "Option1"
    Help describes it as "OptionButton Control"

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,274

    Re: Setting option buttons to false

    Quote Originally Posted by Shaggy Hiker View Post
    It was RadioButtons back then, too. The term is ancient!! Nobody has REAL radio buttons (buttons like that on their radio) anymore, though some of us did back in the day. Option Buttons is a far better name, in my opinion, so if you encountered that, you probably encountered it from somebody who shared my opinion.
    I would agree that RadioButton isn't necessarily the best name as far as being descriptive, given how many people probably have no clue about the origin of the name. That said, the name is the name and, if you use the name, there can be no confusion. there's every chance that someone else might decide that "option button" is an appropriate name for something else, and thus confusion has been sown. If we always use the actual names of things, we always know exactly what we're talking about. I'm not implying that you were suggesting otherwise, but I'm just clarifying my position.

  8. #8
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Setting option buttons to false

    Quote Originally Posted by jmcilhinney View Post
    I would agree that RadioButton isn't necessarily the best name as far as being descriptive, given how many people probably have no clue about the origin of the name.
    If I remember correctly, they had a square shape at that time not a round one...
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width