Results 1 to 2 of 2

Thread: [RESOLVED] Text box cannot used enter

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] Text box cannot used enter

    I try to use enter after I type the number value to get the records, While press enter from the keyboad, I got the messagebox Only number is allowed. So I cannot used enter from keyboard
    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    
      'bila type text, kuar mesg box
     Select Case KeyAscii ' This case statment check that no text can be entered.
                Case vbKeyDelete ' Delete Key
                Case vbKeyBack 'Baskspace key
                Case 48 To 57 ' Number 0-9
                Case Else
                MsgBox "Only number is allowed", vbInformation, "KEY ERROR" ' Error message comes up if you enter text.
               KeyAscii = 0 ' Cancels Keystroke
    End Select

  2. #2
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Text box cannot used enter

    Add another Select Case branch to that with vbKeyReturn then execute what you want.

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

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