PDA

View Full Version : Solved: MsgBox Loop Help



Emoncada
12-06-2007, 10:51 AM
I have something like this

res = InputBox("Please Enter Password")
If res = "candy" Then
It will run a couple of formulas.

I would like so if res doesn't = "candy" then to prompt res2 = MsgBox(""Sorry wrong Answer! Please Try Again!", vbYesNo)
And if clicked Yes loop back to the original res InputBox.
If clicked No To Exit Sub.

Any help would be great. Thanks

Simon Lloyd
12-06-2007, 11:02 AM
Try this:

Sub res()
Dim res As String
Strt:
res = InputBox("Please Enter Password")
If res = "candy" Then
MsgBox "Success"
ElseIf res <> "candy" Then
res2 = MsgBox("Sorry wrong Answer! Please Try Again!", vbYesNo)
If res2 = vbYes Then
GoTo Strt
Else
Exit Sub
End If
End If
End Sub

Emoncada
12-06-2007, 11:07 AM
Perfect!

One more thing do you know how i can have the text entered in the InputBox appear as asterisks? "*****"

Simon Lloyd
12-06-2007, 11:10 AM
Nope! you need to use a userform and textbox if you are planning on using it for a password!

Emoncada
12-06-2007, 11:12 AM
Ok thanks i will use it like that. Thanks Simon