Hi all,
I am trying trying to make both the "Tab Key" behave as the "Enter" key. keys. In otherwords, both the Tab and Enter should acheive the same objective.

I am using the code below but only the "Enter" key is working, but the "Tab" key is not working.

How can I get this accomplished?

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 9 Or KeyAscii = 13 Then cmdGo_Click
End Sub

Thanks.
tgifgemini

it cause TAB key used by VB 6 to move focus from one control to other control. it can't be changed. see tab index on the properties of controls, it used if user press the tab key only. if u want to change the tab function, so how to move tab index purely from vb (without use set focus on other key). but its can't be changed. :)
ok. its from me.
all for the best.

If you want to trap the Tab key in the KeyPress event, you have to disable to TabStop property in all other controls on the form, but you will have to handle moving the control focus yourself. Once the TabStop property is set to false, the Tab key will be trapped in the KeyPress event. Be sure to set the KeyPreview property on the form.

On Error Resume Next
For Each Control In Controls
Control.TabStop = False
Next

when you press the tab key it will jump to the next higher index from its focused control. for example. you have 3 controls and they are text1, text2, command1. if you put first the text1 in the form the tabindex of that control is zero, right? then you put again another control and this time its command1, therefor the tabindex of command1 is 1, then the text2, of course the tabindex of text2 is 2.

so...

if you run the program and presses the tab key, the focus will move according to their tabindex, ergo if the focus is on the text1 and you press the tabkey the focus jumps to ??? yeah to comand1, then to text2.

your problem is you want the focus to be synchronized and must behave like this. from text1 to text2 then to command 1, right?

what I did on this is just simply delete the first control then undo, then delete the next one then undo...delete, undo, delete undo... did you get my point? hahahahaha that's the faster way I used to that problem.... enjoy deleting hehehehehe dont forget to undo the deletion...

Opppps I forget the enter key...

In each control put this code in the Keypress event

If KeyAscii=13 Then
sendkeys "{tab}"
End If

Opppps I forget the enter key...

In each control put this code in the Keypress event

If KeyAscii=13 Then
sendkeys "{tab}"
End If

can someone teach me..i have grid.. the grid have 3 columns and 12 rows and i want use tab as the control to jump to each columns and rows..can somebody give me ade key code for the tab??how to know the keycode for tab??
really appreciate ur helps.
TQ.

Comments
By now, you should know to make a new thread.
This question has already been answered. Start a new discussion instead.