PRB: Can TAB in Error if Value of Option Button Set to False

Last reviewed: June 21, 1995
Article ID: Q85990
The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0
- Microsoft Visual Basic programming system for Windows, version 1.0

SUMMARY

SYMPTOMS

   Setting the Value of an option button to False (0) also sets its
   TabStop property to False. If you set the Value property of an option
   button to False without setting the Value property of another option
   button to True (-1), Visual Basic will allow the user to tab over the
   other option buttons because all the TabStops are set to False.

   This is an invalid state for a group of option buttons. One of the
   option buttons should always be selected (that is, its Value property
   should be set to True, which also sets the TabStop property to True).

CAUSE
   By default, the TabStop property of option buttons is set to True. Once
   an option button is selected at run time, the Value property for the
   other option buttons not selected is set to False, which also sets the
   TabStop property to False. If you just change the Value property of one
   option button to False, and do not set the Value property of another
   option button to True, none of the other option buttons will have their
   TabStop property set to True, and these option buttons will skipped when
   the user presses the TAB key to move through controls at run time.

WORKAROUND
   To avoid this problem, ensure that one of the options in an option group
   is always selected.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start Visual Basic, or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.

  2. Place a command button (Command1), two option buttons (Option1 and Option2) and another command button (Command2) on Form1.

  3. Set the Value property of Option1 to True.

  4. Add the following code to the Command1 Click procedure:

       Sub Command1_Click ()
            Const FALSE = 0
            Option1.Value = FALSE
       End Sub
    
       NOTE: You do not need to setup a Const FALSE = 0 in Visual Basic
       version 2.0 because FALSE is already a keyword in version 2.0.
    
    

  5. Press F5 to run the program.

If you do not click Command1, you can TAB through Option1. However, you will TAB over both option buttons if you click Command1.


Additional reference words: 1.00 2.00 3.00
KBCategory: kbprg kbcode kbprb
KBSubcategory: PrgCtrlsStd


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.