 |
 |

03-29-2003, 08:04 AM
|
|
Newcomer
|
|
Join Date: Mar 2003
Posts: 3
|
|
How can I code a password protection form?
|
Hello guys I want to create two forms. One is password and the other is the main form once the user enters the correct username and password. Im at the most basic level of this type of stuff so I have no clue about arrays or stuff like that, just plain basic password coding. If you see my image, I would like to program it so that after the user enters like 10 characters for Username and 6 characters for Password, all string, he can click on "Password Check" to advance to the next form. How can I do that? Any help is much much appreciated, thanks
|
|

03-29-2003, 08:06 AM
|
|
Restricted
|
|
Join Date: Feb 2003
Posts: 139
|
|
|
Change your text property PasswordChar to whatever you want ( deault is *)
|
|

03-29-2003, 09:54 AM
|
|
Newcomer
|
|
Join Date: Mar 2003
Posts: 3
|
|
|
How can I code the command buttons (Password Check and Cancel)?
|
|

03-29-2003, 10:05 AM
|
 |
Junior Contributor
|
|
Join Date: Feb 2003
Location: University Place, WA
Posts: 274
|
|
ok im some what of a newb too.. but this will work if you dont have that many passwords yous can just use if statements  not very productive but heres what im talkign about :
Code:
Private Sub Command1_Click()
If username.Text = "Cameron Moore" & Pass.Text = "MyPass" Then
Form1.Show
ElseIf username.Text = "Cameron Moore" & Pass.Text <> "MyPass" Then
MsgBox "Invalid Password"
ElseIf username.Text = "Ben Moore" & Pass.Text = "Apass" Then
Form1.Show
ElseIf username.Text = "Ben Moore" & Pass.Text <> "Apass" Then
MsgBox "Invalid Password"
End If
End Sub
This is the long way, im sure theres an easier way. Also If you add a new form one of them is log in, and it is a password check thing to try using it
|
__________________
"Punk rock is freedom" - Kurt Cobian
My Current game Project Black Sun
|

03-29-2003, 10:07 AM
|
 |
Junior Contributor
|
|
Join Date: Feb 2003
Location: University Place, WA
Posts: 274
|
|
Ohh and for the cancel you probley just want it to exit? Do something like
Code:
Private Sub Cancel_Click()
End
End Sub
All this does is exit the program when they press cancel. It's pretty straight forward
|
__________________
"Punk rock is freedom" - Kurt Cobian
My Current game Project Black Sun
|

03-29-2003, 10:14 AM
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
|
Firstly, never use End. Unload all your forms and the program will terminate by itself. Using End forces the program to close without unloading objects, meaning they can linger in memory, not a nice thing.
Secondly, pnklphnts code above should use And instead of & to link conditions.
Lastly, you may wish to load usernames and passwords from a file (Open, Input, Close etc), database (ADO), or the registry (SaveSetting, GetSetting etc).
|
|

03-29-2003, 10:24 AM
|
|
Restricted
|
|
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
|
|
is'nt there a set login form already made??? it might help you just click new form and click the login one then u just need to edit the interface and add the paswords into the code
HOPE IT HELPED :-)
|
|

03-29-2003, 10:27 AM
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
It looks to me like the form is already made, VBProgrammer... 
|
|

03-29-2003, 10:28 AM
|
|
Restricted
|
|
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
|
|
yeah but he hasnt coded it yet has he???
* sorry if i miskaten " 
|
|

03-29-2003, 12:19 PM
|
|
Restricted
|
|
Join Date: Feb 2003
Posts: 139
|
|
Code:
If txtuser.text = "User" then
If txtpass.text = "Password" then
'this happens when both are valid password and username
Else
'this happens when just the password is invalid
End if
Else
'this happens when the username is invalid
End if
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|