G
Garry Jones
I am trying to tab backwards in some textboxes on a UserForm when Shift
and Tab are pressed. I need to call another sub to validate the value
before I allow the user to exit the current textbox.
It works when the user tabs forwards, I use this code for that...
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 9: KeyAscii = 0: ntl 2
End Select
End Sub
(This calls my validation sub "ntl" and sends the number of the textbox
to it, in this example 2)
To tab backwards I am trying
Private Sub TextBox2_KeyDown(ByVal KeyAscii As MSForms.ReturnInteger,
ByVal Shift As Integer)
If Shift <> 1 Then Shift = 0: Exit Sub
If KeyAscii = 9 And Shift = 1 Then ntlbak 2
End Sub
I want this to call my validation sub "ntlbak" and sends the number of
the textbox to it, in this example 2)
But this code does not do it. What am I missing?
Another probably connected problem,
I have noticed a very strange behaviour when I press the ctrl button a
few times, it really messes up the textbox and empties it after
seemingly tabbing the existing value around a little. Can this be
averted?
Garry Jones
Sweden
and Tab are pressed. I need to call another sub to validate the value
before I allow the user to exit the current textbox.
It works when the user tabs forwards, I use this code for that...
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 9: KeyAscii = 0: ntl 2
End Select
End Sub
(This calls my validation sub "ntl" and sends the number of the textbox
to it, in this example 2)
To tab backwards I am trying
Private Sub TextBox2_KeyDown(ByVal KeyAscii As MSForms.ReturnInteger,
ByVal Shift As Integer)
If Shift <> 1 Then Shift = 0: Exit Sub
If KeyAscii = 9 And Shift = 1 Then ntlbak 2
End Sub
I want this to call my validation sub "ntlbak" and sends the number of
the textbox to it, in this example 2)
But this code does not do it. What am I missing?
Another probably connected problem,
I have noticed a very strange behaviour when I press the ctrl button a
few times, it really messes up the textbox and empties it after
seemingly tabbing the existing value around a little. Can this be
averted?
Garry Jones
Sweden