How to Create a Local Password Lock in Visual Basic
Submitted by GeePee on Wednesday, March 25, 2015 - 23:17.
Introduction:
Welcome to my tutorial on how to create a Local Password Lock in Visual Basic. The fact that it's local just means that the password is hardcoded in to the program and can not be changed without editing the source code of the program.
Steps of Creation:
Step 1:
First we want to create a program with; textbox1 - contain password, label1 - to indicate to the user where to input the password, button1 - to check the password.
Step 2:
Next we want to create a couple of variables. We want to set the password in a String variable and also set whether the Capitals in textbox1 (input password) need to be correct or not.
Step 3:
Now on the button1 click action event we want to first check if the entered password is set to a string, if it is we want to check if the caps matter or not...
Step 4:
Finally we just need to check the password appropriately and output the conclusion. If you wanted to redirect them to another form on login you would type the name of the new form followed by ".Show()".
Project Complete!
Below is the full source code and download to the project files.
- Dim password As String = "Yorkiebar"
- Dim capsMatter As Boolean = True
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- If (Not TextBox1.Text = Nothing) Then
- If (capsMatter) Then
- Else
- End If
- End If
- End Sub
- If (capsMatter) Then
- If (TextBox1.Text = password) Then
- MsgBox("Unlocked!")
- Else : MsgBox("Incorrect Password!")
- End If
- Else
- If (TextBox1.Text.ToLower() = password.ToLower()) Then
- MsgBox("Unlocked!")
- Else : MsgBox("Incorrect Password!")
- End If
- End If
- Public Class Form1
- Dim password As String = "Yorkiebar"
- Dim capsMatter As Boolean = True
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- If (Not TextBox1.Text = Nothing) Then
- If (capsMatter) Then
- If (TextBox1.Text = password) Then
- MsgBox("Unlocked!")
- Else : MsgBox("Incorrect Password!")
- End If
- Else
- If (TextBox1.Text.ToLower() = password.ToLower()) Then
- MsgBox("Unlocked!")
- Else : MsgBox("Incorrect Password!")
- End If
- End If
- End If
- End Sub
- End Class
Add new comment
- 156 views