Results 1 to 3 of 3

Thread: [RESOLVED] Input box/ESC key combo hiccup

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    185

    Resolved [RESOLVED] Input box/ESC key combo hiccup

    When using the Inputbox, is there a way to detect the ESC being hit. I have it so the text is already filled in and the user can change the text in the box. If the user hits the ESC key right now, on purpose or by accident it cancels the inputbox and also wipes out what was in the inputbox.

    I do realize that you might be able to detect if it was the ESC key that was pressed but I'm not even sure which KeyAscii code is the ESC key.

    Thanks everyone and have a happy Thanksgiving.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Input box/ESC key combo hiccup

    Pressing ESC key is equivalent to clicking on Cancel button - in either case InputBox results in empty string:
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    Dim newText As String
    Dim defaultText As String
    
        defaultText = "default text"
        newText = InputBox("Enter New Text", "Hello world", defaultText)
        
        If Not (newText = vbNullString Or newText = defaultText) Then
            Text1.Text = newText
        End If
    
    End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    185

    Re: [RESOLVED] Input box/ESC key combo hiccup

    I did forget the vbnull existed. I hadn't ever used it before so that didn't help much either, HA!

    Thanks

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