Results 1 to 5 of 5

Thread: hitting enter in one text box.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    98
    How would I assign something to when I hit enter in a text box ?

    Here is what I have

    text1
    and
    txtConsole

    When I hit enter in text 1 I want the text from text to go into txtConsole.. can anyone help ?
    Visual basic 6.0 Enterprise Edition
    [email protected]

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Set the form's KeyPreview property to False, then place some simple code like
    Code:
    If Keyascii = ?? Then
    txtConsole.Text = Text1.Text
    End if
    in the KeyPress event of the form which responds when you press enter. You'll need to look up the key code, I can't rmember it.

  3. #3
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    vbKeyReturn

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    ..or

    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = 13 Then txtConsole = Text1
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    True, just a little less readable..

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