Results 1 to 7 of 7

Thread: [RESOLVED] problem capturing enter key inside frame

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Resolved [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:
    1. Private Sub Form_KeyPress(KeyAscii As Integer)
    2. If KeyAscii = 13 Then
    3.     '...YOUR PROCEDURE CALL HERE
    4.    
    5. Dim variable_abc
    6. variable_abc = Text1.Text
    7.  
    8. Dim variable_def
    9. variable_def = Text2.Text
    10.  
    11. Dim variable_ghi
    12. variable_ghi = Text3.Text
    13. 'MsgBox "textbox data: " & variable_abc
    14.  
    15. Dim sHTML As String
    16. Dim sURL As String
    17.  
    18. 'Create URL
    19. sURL = "http://localhost/send.php?sessionkey=" & _
    20. gstrSomething & "&text=" & variable_abc & "&site=" & variable_ghi
    21.  
    22. sHTML = Inet1.OpenURL(sURL) 'returns page source
    23. MsgBox "textbox data2: " & sURL
    24. Text1.Text = ""
    25.  
    26. WebBrowser1.Refresh
    27. End If
    28.  
    29. End Sub

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: problem capturing enter key inside frame

    try using the KeyDown event of the TextBox instead...

    vb Code:
    1. Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    2. If KeyCode = vbKeyReturn Then
    3. Text2.Text = Text1.Text
    4. End If
    5. End Sub

  3. #3
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: problem capturing enter key inside frame

    Keypress on a form? You have to set your form's KeyPreview to True in design time.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  5. #5
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: problem capturing enter key inside frame

    And i would suggest using....
    vb Code:
    1. Text1.Text = vbNullString

    instead of

    vb Code:
    1. Text1.Text = ""

    Less memory consuming

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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)
    Last edited by tony007; May 11th, 2007 at 12:20 PM.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [RESOLVED] problem capturing enter key inside frame

    No renaming should have been necessary. Just code moving from one control to another.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width