[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.
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
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