Microsoft KB Archive/191720

= BUG: Option Button Value Changes When Group is Disabled =

Article ID: 191720

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q191720



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.



Steps to Reproduce Behavior
 Create a new Standard EXE project. Form1 is created by default. Add three Option Buttons to Form1.  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  Run the project by pressing the F5 key. When the program starts, the input focus is set to Option2. Double-click somewhere on Form1. Note that the Click event for Option3 is fired when the button is disabled.</li>  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 </li> 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.</li></ol>

Additional query words: kbDSupport kbDSD radio kbVBp kbvbp400bug kbVBp600bug kbVBp500bug kbVBp kbdsd

Keywords: kbbug KB191720

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.