check out the inputbox method in vb help
Option Explicit
Sub test()
Dim result As String
result = Application.InputBox("Enter String", "Test", , , , , , 2)
If result = False Then
MsgBox "cancel pressed"
Exit Sub
Else
MsgBox result
End If
End Sub
--
Gary
"Chua" <(E-Mail Removed)> wrote in message
news:6C004D5F-E54F-479F-86AD-(E-Mail Removed)...
>I use InputBox to display a simple dialog box so that User can enter
> information to be used in a macro. The dialog box has an OK button and a
> Cancel button. How do I activate the Cancel button to perform the function
> that I want?
>
> I tried below code but it will do nothing and exit the program even when
> User click the OK button.
>
> a = InputBox ("Enter Password to Proceed:")
>
> If vbCancel = True Then
> Do nothing
> End If
>
> If a <> "12345" Then
> MsgBox "INVALID PASSWORD !!!" & vbNewLine & "You have no administrator
> rights to access the function.", vbCritical
>
> End
> End If
|