VB tut pass word
Posted: Mon Aug 22, 2005 2:09 pm
ok im still new to vb and my frend showed me how to add a pass word to your vb apps its rilly easy just dubel click the form and put
CODE-
Private Sub Form_Load()
Dim Password As String
Password = InputBox("Please enter your password")
If Password = "Halo rules" Then
MsgBox "Password correct!"
Else
MsgBox "Password incorrect!"
End
End If
End Sub
ok on the 3 line is says Please enter your password you can change that to watever you want it to say like Password please or wat ever so win you load it will say Password please.
On the 4 lin it say Halo rules thats the pass wod you can change that to wat evr pass word you want it to be.
Now on the 5 and 7 lines next to MsgBox you can change thoses to wat ever you want thats just wat it says win u typ the pass word in rite or wrong.
now let say you want it to open your next form win the pass word is rite then under the MsgBox "Password correct!" typ in the name of your next form like frm2 and type .Show so it should look like this
MsgBox "Password correct!"
frm2.Show
now win the pass word it correct it will load your next form but the wind will be open still for a pass word you can just press the x at the top rite or under the frm2.Show typ in the name of your form with .Hide after it so now your line looks like this
MsgBox "Password correct!"
frm2.Show
frm1.Hide
ok 1 more thing now say win some one get the pass werd wrong you want the app to close under the lline MsgBox "Password incorrect!" type in Unload Me
s now your hole script if you did every thing i just showed you should look like this
CODE-
Private Sub Form_Load()
Dim Password As String
Password = InputBox("Please enter your password")
If Password = "Halo rules" Then
MsgBox "Password correct!"
frm2.Show
Frm1.Hide
Else
MsgBox "Password incorrect!"
Unload Me
End
End If
End Sub
i hope all my spelling mistakes dont throw you all off and i hope this tut helps som people out
CODE-
Private Sub Form_Load()
Dim Password As String
Password = InputBox("Please enter your password")
If Password = "Halo rules" Then
MsgBox "Password correct!"
Else
MsgBox "Password incorrect!"
End
End If
End Sub
ok on the 3 line is says Please enter your password you can change that to watever you want it to say like Password please or wat ever so win you load it will say Password please.
On the 4 lin it say Halo rules thats the pass wod you can change that to wat evr pass word you want it to be.
Now on the 5 and 7 lines next to MsgBox you can change thoses to wat ever you want thats just wat it says win u typ the pass word in rite or wrong.
now let say you want it to open your next form win the pass word is rite then under the MsgBox "Password correct!" typ in the name of your next form like frm2 and type .Show so it should look like this
MsgBox "Password correct!"
frm2.Show
now win the pass word it correct it will load your next form but the wind will be open still for a pass word you can just press the x at the top rite or under the frm2.Show typ in the name of your form with .Hide after it so now your line looks like this
MsgBox "Password correct!"
frm2.Show
frm1.Hide
ok 1 more thing now say win some one get the pass werd wrong you want the app to close under the lline MsgBox "Password incorrect!" type in Unload Me
s now your hole script if you did every thing i just showed you should look like this
CODE-
Private Sub Form_Load()
Dim Password As String
Password = InputBox("Please enter your password")
If Password = "Halo rules" Then
MsgBox "Password correct!"
frm2.Show
Frm1.Hide
Else
MsgBox "Password incorrect!"
Unload Me
End
End If
End Sub
i hope all my spelling mistakes dont throw you all off and i hope this tut helps som people out