DOCUMENT:Q192208 03-SEP-1998 [vbwin] TITLE :BUG: UserControl SHIFT+TAB Does Not Follow Tab Sequence PRODUCT :Microsoft Visual Basic for Windows PROD/VER:WINDOWS:6.0 OPER/SYS:WINDOWS KEYWORDS: ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 6.0 --------------------------------------------------------------------- SYMPTOMS ======== When tabbing through constituent controls contained on a UserControl in reverse order (SHIFT+TAB), only the first constituent control is part of the reverse tab sequence. All controls should be part of the reverse tab sequence unless the TabStop property is set to False. Tabbing forward through the controls works as expected. 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. Start a new Standard EXE project in Visual Basic. Form1 is created by default. 2. From the File menu, add an ActiveX Control project. UserControl1 is created by default. 3. Add three TextBox controls to UserControl1. 4. Close the UserControl1 window and add an instance of UserControl1 to Form1. 5. Add a CommandButton to Form1. 6. Save and run the Project. 7. First, tab through all the controls using the TAB key. Now tab backwards through the controls using the SHIFT+TAB key combination. Observe that the only constituent control that receives focus is the first TextBox. Bug: Only the first control on the UserControl is included in the reverse tabbing sequence. 8. Return to design mode and add the following code to UserControl1: Private Declare Function GetKeyState Lib "user32" _ (ByVal nVirtKey As Long) As Integer Private Sub UserControl_EnterFocus() Dim Ctrl As Control Dim LastTab As Integer Dim LastCtrl As Control Dim Count As Integer Count = 0 ' Loop though all the controls and find ' the last control in the tab order For Each Ctrl In Controls If Count = 0 Then LastTab = Ctrl.TabIndex Set LastCtrl = Ctrl End If If Ctrl.TabIndex > LastTab Then LastTab = Ctrl.TabIndex Set LastCtrl = Ctrl End If Count = Count + 1 Next Ctrl ' Set focus to last control in the tab order If GetKeyState(vbKeyShift) Then LastCtrl.SetFocus End If End Sub 9. Save and run the project again. This time the SHIFT+TAB sequence will loop through all the controls in the UserControl. Additional query words: kbDSupport kbDSD kbVBp kbVBp600bug kbCtrlCreate ====================================================================== Version : WINDOWS:6.0 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.