Results 1 to 12 of 12

Thread: Frame

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2010
    Posts
    1,257

    Frame

    I've 4 option buttons in a Frame. Must one be selected when the Form loads or not?
    I've tried setting all .value= False but the top one is still selected.
    Thanks

  2. #2
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,411

    Re: Frame

    My recollection (what I have noticed) is that there is always one selected.
    You could have an additional button and position it out of sight, setting it's Value to true

  3. #3
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,825

    Re: Frame

    Quote Originally Posted by AlexanderBB View Post
    I've 4 option buttons in a Frame. Must one be selected when the Form loads or not?
    I've tried setting all .value= False but the top one is still selected.
    Thanks
    Set the TabIndex property of some other control to 0.
    The option button that gets selected must have TabIndex 0 now, and so it gets the focus and then it gets selected.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2010
    Posts
    1,257

    Re: Frame

    The Frame has tab index of 10 and the four buttons are 11-14. I set another button to tab index 0.
    But the top button in the frame is checked no matter what. I tried setting focus to a textbox but run time error 5. (that puzzles me, you can't set focus to a text box?)
    Also Bobbles, that doesn't remove the check either, the other option becomes checked as well.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,769

    Re: Frame

    "Selected" means something different from "on" (Value = True).

    An option group always has one member control "on" even in a group of 1 control.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2010
    Posts
    1,257

    Re: Frame

    > An option group always has one member control "on" even in a group of 1 control.
    Ok thanks I'll revise strategy to expect that.
    But in Form Load
    txtPath= "Some text"
    txtPath.SetFocus.

    Why does that raise an error 5 ?

  7. #7
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,411

    Re: Frame

    I am attaching a small project demonstrating the lack of any check mark in the 4 option buttons
    Option Button.zip

  8. #8
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,825

    Re: Frame

    A project is worth a thousand words
    Attached Files Attached Files

  9. #9
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,656

    Re: Frame

    1-Do what Eduardo says...will 'fix' (answer) your initial question.

    2-Put txtpath.SetFocus in Form_Activate, not Form_Load. Will 'fix' your error.
    Sam I am (as well as Confused at times).

  10. #10
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,155

    Re: Frame

    Quote Originally Posted by AlexanderBB View Post
    > An option group always has one member control "on" even in a group of 1 control.
    Ok thanks I'll revise strategy to expect that.
    But in Form Load
    txtPath= "Some text"
    txtPath.SetFocus.

    Why does that raise an error 5 ?
    Quote Originally Posted by SamOscarBrown View Post
    1-Do what Eduardo says...will 'fix' (answer) your initial question.

    2-Put txtpath.SetFocus in Form_Activate, not Form_Load. Will 'fix' your error.
    To fully answer that question - it's because loading the form doesn't show the form. You can't set focus to something that isn't shown. In the load event, that's just the first step or several during the creation process. But the form isn't drawn yet, and so controls on it can't have focus set yet. (but you can set text, I know counterinuitive, but that's the way it is.)

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2010
    Posts
    1,257

    Re: Frame

    Thanks for the gen on setFocus. Nice to have that sorted. And the example files, were really helpful.
    At first I could not emulate Eduardos example even after re-ordering the tab indexes so a Text box was 0. The top button in the Frame was True.
    Then the penny dropped, the other controls were not enabled, the idea being they would become enabled depending on which option was True.
    Bobbles method with option top set to -999 also worked ok now.

  12. #12
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,577

    Re: Frame

    This is a similar problem to the ComboBox problem in another thread. When a control has TabIndex=0, it's easy for the user to do something that fouls up that control (such as hit the space bar, or start typing and not realizing where they are). For me, the solution is to always have a TextBox as the TabIndex=0 control, or to have some "off form" (say Left=-999) control that does nothing but has TabIndex=0. This is my "goto" solution for these things. After the form loads and this "off form" control gets the focus, you could even turn off TabStop on this "off form" control so that it's not in the subsequent tab order.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

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