-
Using Passwords for Log-in's
Hi there,
I am a 2nd year computer student & I have a very big end of year project
do & so I would like to do really well in this. The project I'm doing is
for a none existiant company called "The Video Vault" video rental business.
I'm using 3 forms; Form1. is a form with a command button called System Log-In
& when clicked, another Form2. comes up asking the user to Enter there UserName
& Password. If the UserName & Password is correct then the user is actomatically
logged into the system, but if the Password is incorrect then they are asked
to try again until they enter the correct Password. However, the Password
I'm using to allow the user to gain access is "Hello2002", but I don't want
this to be seen or printed, instead I want it to be as seen as most Password
entries are i.e. "*********", but I don't know how to do this. I also want
to be able to have at least 4 different Paswords, but using the same idea
as the one just mentioned. If anyone can help me on this one I'd be forever
greatful, anything at all that might help or put me on the right track. Keeping
in mind that I'm using VB6 & have only been doing VB for about over a year
now ! Thanks !
Regards,
Tricia !
-
Re: Using Passwords for Log-in's
The Text Box control has a property called PasswordChar, just set this to
the character you want to display instead of what is typed.
Sue
"Tricia" <syntia5@hotmail.com> wrote in message
news:3ca3830a$1@10.1.10.29...
>
>
> Hi there,
>
> I am a 2nd year computer student & I have a very big end of year project
> do & so I would like to do really well in this. The project I'm doing is
> for a none existiant company called "The Video Vault" video rental
business.
> I'm using 3 forms; Form1. is a form with a command button called System
Log-In
> & when clicked, another Form2. comes up asking the user to Enter there
UserName
> & Password. If the UserName & Password is correct then the user is
actomatically
> logged into the system, but if the Password is incorrect then they are
asked
> to try again until they enter the correct Password. However, the Password
> I'm using to allow the user to gain access is "Hello2002", but I don't
want
> this to be seen or printed, instead I want it to be as seen as most
Password
> entries are i.e. "*********", but I don't know how to do this. I also want
> to be able to have at least 4 different Paswords, but using the same idea
> as the one just mentioned. If anyone can help me on this one I'd be
forever
> greatful, anything at all that might help or put me on the right track.
Keeping
> in mind that I'm using VB6 & have only been doing VB for about over a year
> now ! Thanks !
>
> Regards,
>
> Tricia !
-
Re: Using Passwords for Log-in's
Hi there,
Thanks Sue for that very handy tip, I tried it & it worked. However, although
it worked using the correct password, it also works using any incorrect password.
The code which I have used for this Password Log-In is as follows :
Dim Name, Pass As String
Dim Password As String
Password = "Hello2002"
Name = txtName.Text
Pass = txtPass.Text
If Password = "Hello2002" Then
MsgBox Name & ", Welcome To The System ! "
Unload frmPass
frmPass.Hide
Load frmMem_Search
frmMem_Search.Show
ElseIf Password <> "Hello2002" Then
MsgBox Name & " , you Have Entered an Incorrect Password,
Please Try Again ! "
txtPass.Text = " "
End If
Can anyone take a look at it and see if any of it can be made more efficent
or could you use a Case statement seen as I want to do the same thing with
3 other passwords for 3 other users of the same system !
Any help at all would be great, Thanks !
Regards,
Tricia !
-
Re: Using Passwords for Log-in's
You prompt them for the password, but you actually set it your
self and then check it against the same value... Of course it always
says you're logged in...
maybe this code should read...
| 'Password = "Hello2002" commented out this line
|
| Name = txtName.Text
| PassWORD = txtPass.Text 'change this line to read PASSWORD, not PASS
D.
"Tricia" <syntia5@hotmail.com> wrote in message news:3ca50b39@10.1.10.29...
|
|
| Hi there,
|
| Thanks Sue for that very handy tip, I tried it & it worked. However, although
| it worked using the correct password, it also works using any incorrect password.
| The code which I have used for this Password Log-In is as follows :
|
| Dim Name, Pass As String
| Dim Password As String
|
| Password = "Hello2002"
|
| Name = txtName.Text
| Pass = txtPass.Text
|
| If Password = "Hello2002" Then
|
| MsgBox Name & ", Welcome To The System ! "
|
| Unload frmPass
| frmPass.Hide
|
| Load frmMem_Search
| frmMem_Search.Show
|
| ElseIf Password <> "Hello2002" Then
|
| MsgBox Name & " , you Have Entered an Incorrect Password,
| Please Try Again ! "
|
| txtPass.Text = " "
|
| End If
|
| Can anyone take a look at it and see if any of it can be made more efficent
| or could you use a Case statement seen as I want to do the same thing with
| 3 other passwords for 3 other users of the same system !
| Any help at all would be great, Thanks !
|
| Regards,
|
| Tricia !
|
-
Re: Using Passwords for Log-in's
Tricia,
YOu have several errors, very common for beginners, in you program:
1)Dim Name, Pass As String
the is IS NOT doing what you think it is doing. In VB, ALL variabels (Each
and every one, individually) MUST be separately declared. That is. the line
MUST read like this:
Dim Name as String, Pass As String
the way you had it, the variable "Name" was actually being declared as a
VARAINT, not as a string.
2) you have assigned a Value to the variable Password (which would appear
to be the password that you want the user to know, and this to enter for
themselves, as you will then test what the user actually entered to see if
they know the correct password - iis that the idea?) You then get the user's
entered password, in the variable called "Pass", but you NEVER compare the
user's entered Password (Pass) to see if it matches the correct Password:
the line that reads
If Password = "Hello2002" Then
should read
If Pass = Password Then
in other words, you want to see it the values entered by the user (which
you are assigning to the variable calle 'Pass' is equal to the value which
you have assigned (in you code) to the variable called 'Password', and if
they ARE Equal (the user correctly entered Hello2002 in the TextBox for the
password), then you let them continue.
3) If they DID not enter the corect password (that is the If....Then part
of the test FAILED (the enttered password WAS NOT equal to the correct value)
your code, as YOU wrote it has in ElseIf test which IS EXACTLY the same thing:
ElseIf Password <> "Hello2002" Then
but the ONLY WAY to get to that line in your program is if the first part
of the test failed (that is "If Password = "Hello2002" Then" WAS FALSE),
which is precisely what "If Password <> "Hello2002" Then" means. So that
ElseIf part is totally UN-NECESSARY...all you really need there is the word
"Else"
what an If...Then...Else...EndIf statement sequence is doing is this:
If (Something is TRUE) then do ONE THING, otherwise (that is, the Something
was FALSE) do ANOTHER thing.
what goes between the word "If" and the word "Then" is some kind of test,
whcih can be either TRUE or FALSE (in you cxase the test is "Password = Pass"--
that is, compare the value stored in the Variable called Password with the
Value in the Varaible called Pass - they are either EXACTLY the same, in
which case the test is TRUE, or they ARE NOT the same, in which case the
test is FALSE. What is very confusing to new programmers is to understand
how the "=" character is being user. Sometimes the "=" means "assign the
VALUE which is on the Right Hand side to the VARIABLE which is on the Left
Hand side" , as in the line of your code 'Password = "Hello2002"' which says
to the program to assign the String of characters "Hello2002" to the variable,
in memory, called Password.
Other times, the "=" character means to COMPARE the two values, and IF they
are the same, then the VALUE of the combination "Variable = Value" id TRUE,
and IF they are not the same, then trhe VALUE id FALSE. IN that situation,
the two values are compred, but the value on the Right IS NOT assigned to
the Variable on the left. This form or the "=" character is ALMOST always
used in the construction of an If....Then line.
Arthur Wood
"Tricia" <syntia5@hotmail.com> wrote:
>
>
>Hi there,
>
>Thanks Sue for that very handy tip, I tried it & it worked. However, although
>it worked using the correct password, it also works using any incorrect
password.
>The code which I have used for this Password Log-In is as follows :
>
> Dim Name, Pass As String
> Dim Password As String
>
> Password = "Hello2002"
>
> Name = txtName.Text
> Pass = txtPass.Text
>
> If Password = "Hello2002" Then
>
> MsgBox Name & ", Welcome To The System ! "
>
> Unload frmPass
> frmPass.Hide
>
> Load frmMem_Search
> frmMem_Search.Show
>
> ElseIf Password <> "Hello2002" Then
>
> MsgBox Name & " , you Have Entered an Incorrect Password,
> Please Try Again ! "
>
> txtPass.Text = " "
>
> End If
>
>Can anyone take a look at it and see if any of it can be made more efficent
>or could you use a Case statement seen as I want to do the same thing with
>3 other passwords for 3 other users of the same system !
>Any help at all would be great, Thanks !
>
>Regards,
>
>Tricia !
>
-
Re: Using Passwords for Log-in's
Hi Arthur,
Thanks for that handy tip ! One more question, could I use a case statement
as opposed to multiple IF.... Then .....Else statements as I want to do the
same thing as regards password log-In's as before with the password "Hello2002",
but this time using 4 different passwords in ths same form as the project
I'm doing is for a ficticious Video Rental Business & has 4 different users
with 4 user entry passwords ! Any help on this one would be great ! Thanks
!
Regards,
Tricia
"Arthur Wood" <wooda@nospam.com> wrote:
>
>Tricia,
> YOu have several errors, very common for beginners, in you program:
>
>1)Dim Name, Pass As String
>the is IS NOT doing what you think it is doing. In VB, ALL variabels (Each
>and every one, individually) MUST be separately declared. That is. the
line
>MUST read like this:
>
>Dim Name as String, Pass As String
>
>the way you had it, the variable "Name" was actually being declared as a
>VARAINT, not as a string.
>
>2) you have assigned a Value to the variable Password (which would appear
>to be the password that you want the user to know, and this to enter for
>themselves, as you will then test what the user actually entered to see
if
>they know the correct password - iis that the idea?) You then get the user's
>entered password, in the variable called "Pass", but you NEVER compare the
>user's entered Password (Pass) to see if it matches the correct Password:
>
>the line that reads
>
>
>If Password = "Hello2002" Then
>
>should read
>
>If Pass = Password Then
>
>in other words, you want to see it the values entered by the user (which
>you are assigning to the variable calle 'Pass' is equal to the value which
>you have assigned (in you code) to the variable called 'Password', and if
>they ARE Equal (the user correctly entered Hello2002 in the TextBox for
the
>password), then you let them continue.
>
>3) If they DID not enter the corect password (that is the If....Then part
>of the test FAILED (the enttered password WAS NOT equal to the correct value)
>your code, as YOU wrote it has in ElseIf test which IS EXACTLY the same
thing:
>
>ElseIf Password <> "Hello2002" Then
>
> but the ONLY WAY to get to that line in your program is if the first part
>of the test failed (that is "If Password = "Hello2002" Then" WAS FALSE),
>which is precisely what "If Password <> "Hello2002" Then" means. So that
>ElseIf part is totally UN-NECESSARY...all you really need there is the word
>"Else"
>
>what an If...Then...Else...EndIf statement sequence is doing is this:
>
>If (Something is TRUE) then do ONE THING, otherwise (that is, the Something
>was FALSE) do ANOTHER thing.
>
>what goes between the word "If" and the word "Then" is some kind of test,
>whcih can be either TRUE or FALSE (in you cxase the test is "Password =
Pass"--
>that is, compare the value stored in the Variable called Password with the
>Value in the Varaible called Pass - they are either EXACTLY the same, in
>which case the test is TRUE, or they ARE NOT the same, in which case the
>test is FALSE. What is very confusing to new programmers is to understand
>how the "=" character is being user. Sometimes the "=" means "assign the
>VALUE which is on the Right Hand side to the VARIABLE which is on the Left
>Hand side" , as in the line of your code 'Password = "Hello2002"' which
says
>to the program to assign the String of characters "Hello2002" to the variable,
>in memory, called Password.
>
>Other times, the "=" character means to COMPARE the two values, and IF they
>are the same, then the VALUE of the combination "Variable = Value" id TRUE,
>and IF they are not the same, then trhe VALUE id FALSE. IN that situation,
>the two values are compred, but the value on the Right IS NOT assigned to
>the Variable on the left. This form or the "=" character is ALMOST always
>used in the construction of an If....Then line.
>
>
>Arthur Wood
>
>
>"Tricia" <syntia5@hotmail.com> wrote:
>>
>>
>>Hi there,
>>
>>Thanks Sue for that very handy tip, I tried it & it worked. However, although
>>it worked using the correct password, it also works using any incorrect
>password.
>>The code which I have used for this Password Log-In is as follows :
>>
>> Dim Name, Pass As String
>> Dim Password As String
>>
>> Password = "Hello2002"
>>
>> Name = txtName.Text
>> Pass = txtPass.Text
>>
>> If Password = "Hello2002" Then
>>
>> MsgBox Name & ", Welcome To The System ! "
>>
>> Unload frmPass
>> frmPass.Hide
>>
>> Load frmMem_Search
>> frmMem_Search.Show
>>
>> ElseIf Password <> "Hello2002" Then
>>
>> MsgBox Name & " , you Have Entered an Incorrect Password,
>> Please Try Again ! "
>>
>> txtPass.Text = " "
>>
>> End If
>>
>>Can anyone take a look at it and see if any of it can be made more efficent
>>or could you use a Case statement seen as I want to do the same thing with
>>3 other passwords for 3 other users of the same system !
>>Any help at all would be great, Thanks !
>>
>>Regards,
>>
>>Tricia !
>>
>
-
Re: Using Passwords for Log-in's
Yes, you could use a Select Case...End Select block, but that approach wil
ALWAYS limit you to the number of cases that you code intom the application.
While it will work for this LEARNING example, waht you will learn by using
this technique cannot be applied to any other situation. And you will in
fact be learning the WRONG way to approach this kind of situation in the
future.
If this is only for the present case, then go with the Select Case...End
Select method.
But for the more general case, you would want to create a User Table in
a database, have the User ID and THEIR password stored in that table. Then
when the user logs in, have them enter their password, and attempt to retrieve
the record from the database that has THAT userID and THAT password. If
you DO gwet a record teruend, then THAT was the correct password. If you
do not get a Record returned, the EITHER the USERID OR the PAsswpord (or
both) were incorrect. The advantage to this way of solving the problem is
then you can have AS MANY USERS as you will EVER nedd, and the program does
not have to be changed. With your approach, if you needed 5 users, then
you would need to change your program to allow for another user. In addition,
with your approach, the user's password is WRITTEN into the program, so 1)
the programmer KNOWS what the password is (not very secure), and 2) the User
CAN NEVER change thier own password to be something else - because that would
require the programmer to change the program.
"Tricia" <wooda@nospam.com> wrote:
>
>
>Hi Arthur,
>
>Thanks for that handy tip ! One more question, could I use a case statement
>as opposed to multiple IF.... Then .....Else statements as I want to do
the
>same thing as regards password log-In's as before with the password "Hello2002",
>but this time using 4 different passwords in ths same form as the project
>I'm doing is for a ficticious Video Rental Business & has 4 different users
>with 4 user entry passwords ! Any help on this one would be great ! Thanks
>!
>
>Regards,
>
>Tricia
>
>"Arthur Wood" <wooda@nospam.com> wrote:
>>
>>Tricia,
>> YOu have several errors, very common for beginners, in you program:
>>
>>1)Dim Name, Pass As String
>>the is IS NOT doing what you think it is doing. In VB, ALL variabels (Each
>>and every one, individually) MUST be separately declared. That is. the
>line
>>MUST read like this:
>>
>>Dim Name as String, Pass As String
>>
>>the way you had it, the variable "Name" was actually being declared as
a
>>VARAINT, not as a string.
>>
>>2) you have assigned a Value to the variable Password (which would appear
>>to be the password that you want the user to know, and this to enter for
>>themselves, as you will then test what the user actually entered to see
>if
>>they know the correct password - iis that the idea?) You then get the user's
>>entered password, in the variable called "Pass", but you NEVER compare
the
>>user's entered Password (Pass) to see if it matches the correct Password:
>>
>>the line that reads
>>
>>
>>If Password = "Hello2002" Then
>>
>>should read
>>
>>If Pass = Password Then
>>
>>in other words, you want to see it the values entered by the user (which
>>you are assigning to the variable calle 'Pass' is equal to the value which
>>you have assigned (in you code) to the variable called 'Password', and
if
>>they ARE Equal (the user correctly entered Hello2002 in the TextBox for
>the
>>password), then you let them continue.
>>
>>3) If they DID not enter the corect password (that is the If....Then part
>>of the test FAILED (the enttered password WAS NOT equal to the correct
value)
>>your code, as YOU wrote it has in ElseIf test which IS EXACTLY the same
>thing:
>>
>>ElseIf Password <> "Hello2002" Then
>>
>> but the ONLY WAY to get to that line in your program is if the first
part
>>of the test failed (that is "If Password = "Hello2002" Then" WAS FALSE),
>>which is precisely what "If Password <> "Hello2002" Then" means. So that
>>ElseIf part is totally UN-NECESSARY...all you really need there is the
word
>>"Else"
>>
>>what an If...Then...Else...EndIf statement sequence is doing is this:
>>
>>If (Something is TRUE) then do ONE THING, otherwise (that is, the Something
>>was FALSE) do ANOTHER thing.
>>
>>what goes between the word "If" and the word "Then" is some kind of test,
>>whcih can be either TRUE or FALSE (in you cxase the test is "Password =
>Pass"--
>>that is, compare the value stored in the Variable called Password with
the
>>Value in the Varaible called Pass - they are either EXACTLY the same,
in
>>which case the test is TRUE, or they ARE NOT the same, in which case the
>>test is FALSE. What is very confusing to new programmers is to understand
>>how the "=" character is being user. Sometimes the "=" means "assign the
>>VALUE which is on the Right Hand side to the VARIABLE which is on the Left
>>Hand side" , as in the line of your code 'Password = "Hello2002"' which
>says
>>to the program to assign the String of characters "Hello2002" to the variable,
>>in memory, called Password.
>>
>>Other times, the "=" character means to COMPARE the two values, and IF
they
>>are the same, then the VALUE of the combination "Variable = Value" id TRUE,
>>and IF they are not the same, then trhe VALUE id FALSE. IN that situation,
>>the two values are compred, but the value on the Right IS NOT assigned
to
>>the Variable on the left. This form or the "=" character is ALMOST always
>>used in the construction of an If....Then line.
>>
>>
>>Arthur Wood
>>
>>
>>"Tricia" <syntia5@hotmail.com> wrote:
>>>
>>>
>>>Hi there,
>>>
>>>Thanks Sue for that very handy tip, I tried it & it worked. However, although
>>>it worked using the correct password, it also works using any incorrect
>>password.
>>>The code which I have used for this Password Log-In is as follows :
>>>
>>> Dim Name, Pass As String
>>> Dim Password As String
>>>
>>> Password = "Hello2002"
>>>
>>> Name = txtName.Text
>>> Pass = txtPass.Text
>>>
>>> If Password = "Hello2002" Then
>>>
>>> MsgBox Name & ", Welcome To The System ! "
>>>
>>> Unload frmPass
>>> frmPass.Hide
>>>
>>> Load frmMem_Search
>>> frmMem_Search.Show
>>>
>>> ElseIf Password <> "Hello2002" Then
>>>
>>> MsgBox Name & " , you Have Entered an Incorrect Password,
>>> Please Try Again ! "
>>>
>>> txtPass.Text = " "
>>>
>>> End If
>>>
>>>Can anyone take a look at it and see if any of it can be made more efficent
>>>or could you use a Case statement seen as I want to do the same thing
with
>>>3 other passwords for 3 other users of the same system !
>>>Any help at all would be great, Thanks !
>>>
>>>Regards,
>>>
>>>Tricia !
>>>
>>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|