| | |
VB6 - Make Tab key also an "Enter" key.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jul 2007
Posts: 113
Reputation:
Solved Threads: 0
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?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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.

ok. its from me.
all for the best.
Last edited by Estella; Jan 16th, 2008 at 3:02 pm.
•
•
Join Date: Apr 2007
Posts: 106
Reputation:
Solved Threads: 16
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
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...
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...
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
Opppps I forget the enter key...
In each control put this code in the Keypress event
If KeyAscii=13 Then
sendkeys "{tab}"
End If
In each control put this code in the Keypress event
If KeyAscii=13 Then
sendkeys "{tab}"
End If
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
•
•
Join Date: Dec 2007
Posts: 17
Reputation:
Solved Threads: 0
•
•
•
•
Opppps I forget the enter key...
In each control put this code in the Keypress event
If KeyAscii=13 Then
sendkeys "{tab}"
End If
really appreciate ur helps.
TQ.
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: textbox to label
- Next Thread: VB Project
Views: 7402 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
6 429 2007 access activex add age append application basic beginner birth c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





