help please!!

Craig AS

New Member
Joined
Mar 6, 2002
Messages
26
I have a project which requires a password to allow specific users to log on. I have tryed using this:

Private Sub CommandButton1_Click()
Dim strPass As String

strPass = TextBox1.Text

Do Until iTries = 3
If strPass = "Secret" Then
MsgBox "Log in OK!"
Run "LogInOk"
End
End If
MsgBox "Log in NOT OK!"
iTries = iTries + 1
Exit Do
Loop

If iTries = 3 Then Unload Me

End Sub

However when I press the macro command button nothing happens, I have no Idea what is going on. Any help will be appreciated.
Thanks alot
Craig
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi Craig, This code looks very familiar :eek:)

Try this

Dim strPass As String
Dim iTries As Integer
Private Sub CommandButton1_Click()


strPass = TextBox1.Text

Do Until iTries = 3
If strPass = "Secret" Then
MsgBox "Log in OK!"
Run "LogInOk"
End
End If
MsgBox "Log in NOT OK!"
iTries = iTries + 1
Exit Do
Loop

If iTries = 3 Then Unload Me

End Sub


The bit I modified was your variable iTries It MUST be at the Module level else it will loose it's value each time.
 
Upvote 0
lol, yeah it does look familiar, thanks for that by the way. I'll see how this works now then, thanks alot

Craig
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top