Option Explicit
Private Sub CommandButton1_Click()
Dim x As String
Dim i As Integer
Me.MultiPage1.Pages(1).Visible = False
101:
x = InputBox("Enter your Password.", "Password Required")
If x = "123" Then
'Success!
'Continue with your macro because the user typed the correct macro
MsgBox "Welcome!"
Me.MultiPage1.Pages(1).Visible = True
Me.MultiPage1.Value = 1
Else
If i <= 1 Then
MsgBox "Invalid Password. Try again. You have " & (2 - i) & " tries left."
i = i + 1
GoTo 101:
Else
MsgBox "Incorrect password entered too many times. Try again later."
Application.Visible = False
Application.Quit
Exit Sub
End If
End If
End Sub
Private Sub UserForm_Initialize()
Me.MultiPage1.Pages(1).Visible = False
End Sub