Hi guys
Is there a way by which i can control the action of tab key???
Printable View
Hi guys
Is there a way by which i can control the action of tab key???
Its very easy: renumber the "TabIndex" property of the parts on your window.
Merry Christmas,
Ingrid
hi Ingrid
Merry Christmas
i didn't mean controlling using tabindex what i want to know can t tapped the tab key????? let say I have a text box text1 nd what i want is when a user presses tab key on this text box i want to raise an event.
any idea?????
there's a couple of ways of handling this.
One, if your tabbing into the textbox(text1), you can place your code in the the "text1_Got Focus()" procedure. If your tabbing out of the textbox when you want the code to run, use the "text1_Validate()" procedure. Hope this helps.
Scott
From what I gather what you need is the grab the Key Press or Key Up event! I will have a play and post the code!
------------------
Code:Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 9 Then
MsgBox "No Tab Keys Here!"
KeyAscii = 0
End If
End Sub
I am interested now! I have tried the KeyDown,KeyPress and KeyUp events none of them trigger when pressing tab! THAT SUCKS a key is being pressed!
So if someone can help this dude out it would be interesting to see a way around this!
Thanks
ALF
ALFWare
I am interested now! I have tried the KeyDown,KeyPress and KeyUp events none of them trigger when pressing tab! THAT SUCKS a key is being pressed!
So if someone can help this dude out it would be interesting to see a way around this!
Thanks
ALF
ALFWare
The code I posted worked perfectly for me, using the KeyPress event in a multiline textbox.
HI
Clunietp, your code is working becase there is only one control on the form try to put one more and then run the same code no msg will generat.
What I have found is when have only one control then vb raise event if there is more then one control on the form vb Suppress the event and set the focus to the next control.
so what we need to do is to stop this Suppress process so that we can control that event.
We can do this by using lostfocus but the prob is this is raised many times and we don't have any method to know the cause of the event to manage the process.
Thanx Manish
Hi,
that's how it works: Suppose it's the Text1 control you need to trap the tab-key.
The solution is, to set the TabStop property to false for every control. The 'on error resume next' because not all controls have a TabStop property. You can build that more sophisticated, store the original value somewhere etc.Code:Private Sub Text1_GotFocus()
Dim ctl As Control
For Each ctl In Me.Controls
On Error Resume Next
ctl.TabStop = False
Next
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab Then
'Do whatever you want to
End If
End Sub
Private Sub Text1_LostFocus()
Dim ctl As Control
For Each ctl In Me.Controls
On Error Resume Next
ctl.TabStop = True
Next
End Sub
I think this can solve the prob.
thanx a lot RogerH.
Thanx Manish