Just trying different little programs.
I was looking though a book on Visual Basic .Net and came across a little password-protection program (A very simple one).
Problem is, that this was written for VB6, not the 2008 version, so i did a little editing as shown below:
'Start by declaring variables Dim Password As String Dim Attempt As Integer Dim Inputpassword As String 'Now move on to defining what the variables contain Password = "secret" Attempt = 0 'Now tell the program what to do Do Attempt = Attempt + 1 Inputpassword = InputBox("Enter password. This program will close after 3 incorrect attempts. This is attempt " & "Number " & Attempt) 'Tell the program when it is to end If Attempt = 3 Then Me.Close() Else Loop Until (Inputpassword = Password)
The only thing i am having difficulty is with the line at the end. Even though it has been told it needs to close if more than three attempts are made, it keeps trying to create a fourth attempt and is fighting against the If statement.
How do i get the inputbox to close without it conflicting with the loop? I thought maybe an End If statement at the end would help, but it doesn't.