[RESOLVED] problem capturing enter key inside frame
I have a textbox inside frame and want to capture enter key using the code below but it never works. I had the same textbox outside frame and it was working !! could any one tell me how to fix this problem?thanks
1 Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
'...YOUR PROCEDURE CALL HERE
Dim variable_abc
variable_abc = Text1.Text
Dim variable_def
variable_def = Text2.Text
Dim variable_ghi
variable_ghi = Text3.Text
'MsgBox "textbox data: " & variable_abc
Dim sHTML As String
Dim sURL As String
'Create URL
sURL = "http://localhost/send.php?sessionkey=" & _
gstrSomething & "&text=" & variable_abc & "&site=" & variable_ghi
sHTML = Inet1.OpenURL(sURL) 'returns page source
MsgBox "textbox data2: " & sURL
Text1.Text = ""
WebBrowser1.Refresh
End If
End Sub
Re: problem capturing enter key inside frame
try using the KeyDown event of the TextBox instead...
vb Code:
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Text2.Text = Text1.Text
End If
End Sub
Re: problem capturing enter key inside frame
Keypress on a form? You have to set your form's KeyPreview to True in design time.
Re: problem capturing enter key inside frame
You posted code for a Form KeyPress but your question is about a textbox keypress.
Which one is giving you the problem?
If it is in a frame, I suspect it is the textbox, correct?
What is in your textboxs keypress event?
Re: problem capturing enter key inside frame
And i would suggest using....
vb Code:
Text1.Text = vbNullString
instead of
Less memory consuming ;)
Re: problem capturing enter key inside frame
Quote:
Originally Posted by Hack
You posted code for a Form KeyPress but your question is about a textbox keypress.
Which one is giving you the problem?
If it is in a frame, I suspect it is the textbox, correct?
What is in your textboxs keypress event?
Problem solved i rename it to:
Private Sub Text1_KeyPress(KeyAscii As Integer)
instead of :
Private Sub Form_KeyPress(KeyAscii As Integer)
or
Private Sub frame1_KeyPress(KeyAscii As Integer)
Re: [RESOLVED] problem capturing enter key inside frame
No renaming should have been necessary. Just code moving from one control to another.