DOCUMENT:Q191720 24-AUG-1998 [vbwin] TITLE :BUG: Option Button Value Changes When Group is Disabled PRODUCT :Microsoft Visual Basic for Windows PROD/VER: OPER/SYS:WINDOWS KEYWORDS: ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0 - Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0 --------------------------------------------------------------------- SYMPTOMS ======== You have a group of Option Buttons on a Visual Basic Form. When you disable them from code, the last one disabled will have its Value property changed to True, causing the Click event for that button to fire. This occurs only when all of the option buttons are disabled. CAUSE ===== The problem occurs when the buttons are disabled while the current input focus is on one of the buttons. As each button is disabled in turn, the tab order advances the focus to the next available button in the option group. When the last button is disabled, its Value property is set to True, and its Click event is fired. RESOLUTION ========== This behavior does not occur if the input focus is moved to another control before the buttons are disabled. STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- 1. Create a new Standard EXE project. Form1 is created by default. 2. Add three Option Buttons to Form1. 3. Paste the following code into Form1's code window: Option Explicit Private Sub Form_Load() Option2.Value = True End Sub Private Sub Form_DblClick() Option1.Enabled = False Option2.Enabled = False Option3.Enabled = False End Sub Private Sub Option3_Click() MsgBox "Option3 Click" End Sub 4. Run the project by pressing the F5 key. When the program starts, the input focus is set to Option2. 5. Double-click somewhere on Form1. Note that the Click event for Option3 is fired when the button is disabled. 6. To resolve the problem, add a Text Box to Form1. Then add the following line at the start of the Form_DblClick event: Text1.SetFocus 7. Re-run the program and double-click somewhere on Form1. This time the Click event of Option3 should not fire when the control is disabled. Additional query words: kbDSupport kbDSD radio kbVBp kbvbp400bug kbVBp600bug kbVBp500bug kbVBp kbdsd ====================================================================== Platform : WINDOWS Issue type : kbbug ============================================================================= 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. Copyright Microsoft Corporation 1998.