Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > How can I code a password protection form?


Reply
 
Thread Tools Display Modes
  #1  
Old 03-29-2003, 08:04 AM
Ex-TerMinator Ex-TerMinator is offline
Newcomer
 
Join Date: Mar 2003
Posts: 3
Question 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
Attached Images
File Type: jpg Password.jpg (77.0 KB, 34 views)
Reply With Quote
  #2  
Old 03-29-2003, 08:06 AM
Mephisto666 Mephisto666 is offline
Restricted
 
Join Date: Feb 2003
Posts: 139
Default

Change your text property PasswordChar to whatever you want ( deault is *)
Reply With Quote
  #3  
Old 03-29-2003, 09:54 AM
Ex-TerMinator Ex-TerMinator is offline
Newcomer
 
Join Date: Mar 2003
Posts: 3
Default

How can I code the command buttons (Password Check and Cancel)?
Reply With Quote
  #4  
Old 03-29-2003, 10:05 AM
pnklphnts's Avatar
pnklphnts pnklphnts is offline
Junior Contributor
 
Join Date: Feb 2003
Location: University Place, WA
Posts: 274
Default

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
Reply With Quote
  #5  
Old 03-29-2003, 10:07 AM
pnklphnts's Avatar
pnklphnts pnklphnts is offline
Junior Contributor
 
Join Date: Feb 2003
Location: University Place, WA
Posts: 274
Default

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
Reply With Quote
  #6  
Old 03-29-2003, 10:14 AM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

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).
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #7  
Old 03-29-2003, 10:24 AM
Squidge Squidge is offline
Restricted
 
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
Default

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 :-)
Reply With Quote
  #8  
Old 03-29-2003, 10:27 AM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

It looks to me like the form is already made, VBProgrammer...
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #9  
Old 03-29-2003, 10:28 AM
Squidge Squidge is offline
Restricted
 
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
Default

yeah but he hasnt coded it yet has he???

* sorry if i miskaten "
Reply With Quote
  #10  
Old 03-29-2003, 12:19 PM
Mephisto666 Mephisto666 is offline
Restricted
 
Join Date: Feb 2003
Posts: 139
Default

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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
multi connections, one port? burningodzilla Communications 5 08-02-2005 05:04 PM
CODE 2 CHANGE PASSWORD &S TORE ITS NEW VALUE NEEDED sh33p16 Word, PowerPoint, Outlook, and Other Office Products 4 06-21-2003 11:29 PM
Text formattting watkins General 16 04-23-2002 12:01 PM
VB Code and Form (& objects one form) out of sync - Refresh problem JohnB_UK General 1 03-03-2002 04:00 AM
WinSock vbsupernewbie Communications 1 09-12-2001 10:20 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->