|
-
Nov 8th, 1999, 08:45 AM
#1
Thread Starter
Hyperactive Member
that's it!
-
Nov 8th, 1999, 08:52 AM
#2
Fanatic Member
Try this:
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
'do whatever you want
End If
End Sub
------------------
Visual Basic Programmer (at least I want to be one)
------------------
PolComSoft
You will hear a lot about it.
[This message has been edited by QWERTY (edited 11-08-1999).]
-
Nov 8th, 1999, 08:58 AM
#3
Thread Starter
Hyperactive Member
-
Mar 21st, 2002, 02:23 AM
#4
New Member
The ENTER key is never detected on my system through AScii vbKey Return. I have even tried toggling the keyPreview option of the form.
I have also tried the following code but the ENTER key does not return anything. Others work well.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1: MsgBox "F1 is your friend."
Case vbKeyDelete: MsgBox "F2 could copy text."
Case vbKeyReturn: MsgBox "F3 could paste text."
Case vbKeyF4: MsgBox "F4 could format text."
End Select
End Sub
Please reply on my email address.
-
Mar 21st, 2002, 04:14 AM
#5
Frenzied Member
Simple.
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
MsgBox "Enter was pressed!"
End If
End Sub
Does this help?
-
Mar 21st, 2002, 04:27 AM
#6
New Member
ENTER Key Problem
Dear Members thanks a lot for such quick response.I am thrilled. Mr Ram's observation regarding change in focus is perhaps what I am experiencing.
Mr mcai has suggested putting the code in the Text sub. It works there.
I am making a Windows like calculator where bith mouse and keyboard inputs are acceptable even if the user enters half the math expression with mouse and then decides to use keyboard .
Is there any method where I can put the detailed ( e.g Equals formula for +,-,/,sqr) code in the button's click sub routine and then call this routine in the button's KeyPress routine, thus reducing file size.
-
Mar 21st, 2002, 04:34 AM
#7
Frenzied Member
Excuse me, but are you saying that your program is an advanced
calculation program? A program that you can enter "5^2+(2^3)"
and it will return 33 ? If that it what you mean, this program
sounds very useful.
-
Mar 21st, 2002, 04:52 AM
#8
New Member
ENTER Key Problem
Well I don't say that my simple Math calculator is an advanced program at the moment. But it needs to mimic the Windows calculator which does not mind which part of an expression is comming from mouse click and which by keyboard. At the same time I need to keep the program size small i.e by avoiding repeating the code for click and keypress events.
hope I am able to convey my message.
I am really impressed by your quick responses. My friend is with me and finding it unbelievable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|