Results 1 to 5 of 5

Thread: vbKeyEnter...simple question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537
    howdy,
    how do I have a text box, that after entering text and hitting the ENTER key, my code runs.
    example.

    Private Sub Text2_KeyPress(KeyAscii As Integer)
    dim num as integer
    num = text2.text
    If KeyAscii = 13 Then
    label1.caption = num +5
    End If
    End Sub

    I don't know if this makes sense but I bet someone can
    easily figure it out.
    thanks
    pnj

  2. #2
    Guest
    Try this.

    Code:
    Private Sub Text2_KeyPress(KeyAscii As Integer)
    
        Dim num As Integer
        num = Val(Text2.Text)
        
        If KeyAscii = 13 Then
            Label1.Caption = num + 5
        End If
        
    End Sub

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    What you have there should work. What's happening when you run it?
    "It's cold gin time again ..."

    Check out my website here.

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

    <?>

    Bruce, Megatron is correct..you need a value for
    math calculations.

    It can't work...text2.text is string by default.
    "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

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