Stephanie0205
Board Regular
- Joined
- Apr 14, 2005
- Messages
- 152
Is it possible to determine if someone hits the cancel button on an inputbox? As far as I can tell, the vbcancel option is not available.
'...
Dim strResponse As String
strResponse = InputBox("Please enter a value:")
If strResponse = vbNullString Then MsgBox "You pressed Cancel!"
'...
Public Sub Demo()
Reply = Application.InputBox("blah blah blah", "Title here")
If Reply = False Then
MsgBox ("CANCEL BUTTON WAS PRESSED")
End If
End Sub
Public Sub Demo2()
Reply = Application.InputBox("blah blah blah", "Title here")
If Reply = False Then Exit Sub
MsgBox ("CANCEL BUTTON WAS NOT PRESSED")
End Sub
Dim dt As Date
dt = InputBox("Please enter date.")
If dt = vbNullString Then
...
Dim dt As Date
dt = Application.InputBox("Please enter date.")
If dt = False Then
...
Some people only use the Application.InputBox method when they want to trap cancel but it is do-able with the function InputBox as an example below using strptr:Stephanie0205 said:Is it possible to determine if someone hits the cancel button on an inputbox? As far as I can tell, the vbcancel option is not available.