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
VB tut pass word
-
- Posts: 5426
- Joined: Sat Jul 24, 2004 12:12 pm
- Location: I'm a Paranoid
- Contact:
![]() |
![]() |
-
- Posts: 16
- Joined: Wed Jul 20, 2005 4:15 pm
-
- Posts: 325
- Joined: Mon Mar 22, 2004 3:59 pm
- Location: Everywhere but nowhere
- Contact:
Yes a very insecure way of doing it. And it should just be
Unload Me
...instead of...
Form1.Hide
Unless you wanted to set a timer for activity (keypress, or mousemouse events) and then bring up the form again. But even so you could still use the .Show property to load it again.
There are also better ways of doing this so you can set multiple accounts (login names) each with their own password or multiple passwords, up to you. A bunch of things are possible with If statements and text boxes too. But yes, very simple way, although I believe I already saw your friend's post about this?
Unload Me
...instead of...
Form1.Hide
Unless you wanted to set a timer for activity (keypress, or mousemouse events) and then bring up the form again. But even so you could still use the .Show property to load it again.
There are also better ways of doing this so you can set multiple accounts (login names) each with their own password or multiple passwords, up to you. A bunch of things are possible with If statements and text boxes too. But yes, very simple way, although I believe I already saw your friend's post about this?