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: tgifgemini is an unknown quantity at this point 
Solved Threads: 0
tgifgemini tgifgemini is offline Offline
Junior Poster

VB6 - Make Tab key also an "Enter" key.

 
0
  #1
Jan 16th, 2008


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)
  1. Private Sub Text2_KeyPress(KeyAscii As Integer)
  2. If KeyAscii = 9 Or KeyAscii = 13 Then cmdGo_Click
  3. End Sub

Thanks.
tgifgemini
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 97
Reputation: Estella is an unknown quantity at this point 
Solved Threads: 6
Estella's Avatar
Estella Estella is offline Offline
Junior Poster in Training

Re: VB6 - Make Tab key also an "Enter" key.

 
0
  #2
Jan 16th, 2008
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.
Last edited by Estella; Jan 16th, 2008 at 3:02 pm.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 84
Reputation: VBNick is an unknown quantity at this point 
Solved Threads: 1
VBNick VBNick is offline Offline
Junior Poster in Training

Re: VB6 - Make Tab key also an "Enter" key.

 
0
  #3
Jan 16th, 2008
Private Sub Text1_LostFocus()
cmdGo_Click
End Sub
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 106
Reputation: SCBWV is an unknown quantity at this point 
Solved Threads: 16
SCBWV SCBWV is offline Offline
Junior Poster

Re: VB6 - Make Tab key also an "Enter" key.

 
0
  #4
Jan 16th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 43
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: VB6 - Make Tab key also an "Enter" key.

 
0
  #5
Jan 21st, 2008
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...
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 43
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: VB6 - Make Tab key also an "Enter" key.

 
0
  #6
Jan 21st, 2008
Opppps I forget the enter key...

In each control put this code in the Keypress event

If KeyAscii=13 Then
sendkeys "{tab}"
End If
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 17
Reputation: bungek84 is an unknown quantity at this point 
Solved Threads: 0
bungek84 bungek84 is offline Offline
Newbie Poster

Re: VB6 - Make Tab key also an "Enter" key.

 
-1
  #7
Feb 15th, 2009
Originally Posted by jireh View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 84
Reputation: VBNick is an unknown quantity at this point 
Solved Threads: 1
VBNick VBNick is offline Offline
Junior Poster in Training

Re: VB6 - Make Tab key also an "Enter" key.

 
0
  #8
Feb 18th, 2009
1. Open Visual Basic
2. Press F2
3. search for "KeyCodeConstants"
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 17
Reputation: bungek84 is an unknown quantity at this point 
Solved Threads: 0
bungek84 bungek84 is offline Offline
Newbie Poster

Re: VB6 - Make Tab key also an "Enter" key.

 
0
  #9
Feb 18th, 2009
TQ. it's really help me.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 7402 | Replies: 8
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC