-
I am using a input box to ask quantity and saving it for a calculation. But i need to know how, what if the user clicks on cancel, how do I make the program end instead of giving an error message.
temp = msgbox("blah", vbYesNo, "blah2")
if temp = vbYes then
end
end if
this works with msgboxes but not with inputboxes, is there a solution????
-
Code:
Dim TheInput As String
TheInput = Inputbox("Please enter something")
If TheInput = "" Then
Msgbox "You Clicked Cancel."
Else
Msgbox "Thanks for entering something!"
End If
-
The only problem with that is the user could just click ok without entering a value executing the "Cancel" code.
If you want a more reliable way then download my Dialog Extensions DLL, set a reference to it then use the InputBoxEx() function, i.e.
Code:
Private Sub Command1_Click()
On Error GoTo Canceled
Caption = InputBoxEx("Enter Something", CancelError:=True)
Exit Sub
Canceled:
Caption = "Canceled"
End Sub