VB tut pass word

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
BlairBitch





Posts: 150
Joined: Mon Jan 10, 2005 9:15 pm

VB tut pass word

Post by BlairBitch »

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
Patrickssj6




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post by Patrickssj6 »

thats cool
...left for good
User avatar
Agent ME




Articulatist 500

Posts: 881
Joined: Tue Jun 21, 2005 6:00 pm
Location: California, USA
Contact:

Post by Agent ME »

Cool, but if it were for something very important, you'd want to encrypt the password because other wise someone could open it in a hex editor and find the password. I think the XOR operator would be useful here.
twolvesfan369





Posts: 16
Joined: Wed Jul 20, 2005 4:15 pm

Post by twolvesfan369 »

yeah a basic way to do that is like do
length = len(text1.text)
add mid() in there
and convert using
asc() or hex()..thers jsu so many i cant think of now
Onetoomanysodas





Posts: 325
Joined: Mon Mar 22, 2004 3:59 pm
Location: Everywhere but nowhere
Contact:

Post by Onetoomanysodas »

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?
Post Reply