Hi, I have tried to find literature and web search pertaining to this subject with no luck, maybe someone can tell me if it is possible or not. My app is finance based and for obvious reasons has many numeric text fields on the forms. The natural instinct when the user fills in the last field is to press "Enter" on the keyboard. At the moment i have butons that say calculate to execute the script. Is there any way to have the last text box on a form execute a certain script when enter is pressed after data is captured in that field? Thanks
VB6 Enter button
Collapse
X
-
-
The button works fine - the click event is operational. I am asking about the "enter" button on your keyboard that will execute a code. In other words the application links to the enter button on your keyboard? Does this make sense?Originally posted by debasisdasOn the click event of the button you want to execute the code ,make that buton default button by setting the default property of the button to TRUE.Comment
-
Ok, sorry see what you meanI Can the same be done for a text box as there is no default setting?Originally posted by WernerhThe button works fine - the click event is operational. I am asking about the "enter" button on your keyboard that will execute a code. In other words the application links to the enter button on your keyboard? Does this make sense?Comment
-
Try this in textbox keypress event,Originally posted by WernerhOk, sorry see what you meanI Can the same be done for a text box as there is no default setting?
[CODE=vb]If keyAscii = 13 then cmdName_Click()[/CODE]Comment
-
-
Hi Wernerh!
May this help u along with the above two explained u
Better u take texts array and use...Code:Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Text2.SetFocus End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Text3.SetFocus End Sub
RESPOND whether I got ur point...Code:Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) If Index <> Text1.Count - 1 Then If KeyAscii = 13 Then Text1(Index + 1).SetFocus Else 'create your command MsgBox "Hi" End If End Sub
ALL THE BEST!Comment
-
does vb6 have an "Accept Button" property under the form's properties window?Originally posted by Mohan KrishnaHi Wernerh!
May this help u along with the above two explained u
Better u take texts array and use...Code:Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Text2.SetFocus End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Text3.SetFocus End Sub
RESPOND whether I got ur point...Code:Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) If Index <> Text1.Count - 1 Then If KeyAscii = 13 Then Text1(Index + 1).SetFocus Else 'create your command MsgBox "Hi" End If End Sub
ALL THE BEST!Comment
-
If I understand the question properly, I think the KeyPreview property is what you're after. However, it may depend on what version of VB you're using.Originally posted by captainphoenixdoes vb6 have an "Accept Button" property under the form's properties window?Comment
-
hi
following lines may help you.
set the KeyPreview property of the Form to True either in properties window or by typeing Keypreview = true in form_load event.
in the form_keydown event write following code
if keycode = vbkeyreturn then
if me.activecontor l.name = "textbox name" then ''use this line if neccessary
run script
endif
endif
you can also check the type of the active control as
if typeof me.activecontro l is textbox then
do something
endif
regards
manpreet singh dhillon hoshiarpurComment
Comment