Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone explain how text gets smaller and smaller each time you toggle through a texbox?

Status
Not open for further replies.

tedb13

Technical User
Jan 20, 2011
41
CA
I would also like to know if there is anyone out there who knows how to toggle through the textboxes using Tab and Shift+Tab.

Code:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    'If KeyCode = vbKeyTab Then TextBox2.Activate
    If KeyCode = vbKeyUp Then TextBox3.Activate
    If KeyCode = vbKeyDown Then TextBox2.Activate
End Sub

Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    'If KeyCode = vbKeyTab Then TextBox3.Activate
    If KeyCode = vbKeyUp Then TextBox1.Activate
    If KeyCode = vbKeyDown Then TextBox3.Activate
End Sub

Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    'If KeyCode = vbKeyTab Then TextBox1.Activate
    If KeyCode = vbKeyUp Then TextBox2.Activate
    If KeyCode = vbKeyDown Then TextBox1.Activate
End Sub

It's always better to ask stupid questions; stupid questions have been known to reduce the frequency of stupid mistakes. :eek:)
 
Set the TabIndex property for each Control in the required order and it will just work, without any further code.
 
unfortunately this is not a userform or I would have done just that. I am using activex control textbox. I need to code the tab order. Even if I could set the Tab order, the problem in my querry is the shrinking of the text each time I toggle through them. Thanks all the same.

It's always better to ask stupid questions; stupid questions have been known to reduce the frequency of stupid mistakes. :eek:)
 
You can:
Code:
If KeyCode = vbKeyTab Then
    If Shift And 1 Then
        TextBox3.Activate
    Else
        TextBox2.Activate
    End If
End If
See the help for KeyDown, KeyUp events. I noticed that fmShiftMask, fmCtrlMask, and fmAltMask constants listed in the help file do not exist, so one needs to use values (1, 2 and 4 respectively) instead.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top