By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,813 Members | 1,236 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,813 IT Pros & Developers. It's quick & easy.

I need help with a login form too

P: n/a
Hello.
I was wondering if someone could help me too with a login form. Upon
startup, I have to display a password screen and it should accept a
user name and password. User name can be anything non-blank. If
there is no user name, an appropriate error message must be displayed.
All of the following passwords are valid IT160, VB2Manager, BackDoor.
No other password is valid. It must allow the user to enter the
password in any case. If an invalid password is enterd, i need to
display an appropriate message. If no password is entered or if the
password is incorrect after three tries, display a sorry message and
exit the program. I am using VB.Net and it is an MDI form. Ineed to
display the password screen then the splash screen and the the parent
form. Please help. I am so confused. Thanks
Nov 20 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
You forgot to include the e-mail address of your instructor... or will you
handle the part where you turn it in for a grade?

Is there any part of the lesson which you are not confused about? We could
build from there unless you just want the A+ and prefer to skip the coding
part of things?

"carr4895" <CA******@YAHOO.COM> wrote...
Hello.
I was wondering if someone could help me too with a login form. Upon
startup, I have to display a password screen and it should accept a
user name and password. User name can be anything non-blank. If
there is no user name, an appropriate error message must be displayed.
All of the following passwords are valid IT160, VB2Manager, BackDoor.
No other password is valid. It must allow the user to enter the
password in any case. If an invalid password is enterd, i need to
display an appropriate message. If no password is entered or if the
password is incorrect after three tries, display a sorry message and
exit the program. I am using VB.Net and it is an MDI form. Ineed to
display the password screen then the splash screen and the the parent
form. Please help. I am so confused. Thanks

Nov 20 '05 #2

P: n/a
Hard coding passwords is not a good idea but in the event that you are doing
this, the code snippet here will do as you requested.

Place this into your Login button click procedure and away you go.

I hope this is not for a homework assignment for a programming course.

Dim strUserName As String

Dim strPassword As String

Static intPwdCounter As Integer

If Not intPwdCounter = 2 Then

If Not txtUserName.Text = "" Then

strUserName = txtUserName.Text

strPassword = txtPwd.Text

If UCase(strPassword) = "IT160" Or UCase(strPassword) = "VB2MANAGER" Or
UCase(strPassword) = "BACKDOOR" Then

Dim mySplash As New frmSplash

mySplash.Show()

Me.Hide()

Else

intPwdCounter += 1

MessageBox.Show("Incorrect Password! You have " & 3 - intPwdCounter & "
tries left.", "Password error", MessageBoxButtons.OK, MessageBoxIcon.Error)

txtPwd.Focus()

Exit Sub

End If

Else

MessageBox.Show("Please enter a username to continue.", "Login Error",
MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)

txtUserName.Focus()

Exit Sub

End If

Else

MessageBox.Show("Access Denied!", "Incorrect Login", MessageBoxButtons.OK,
MessageBoxIcon.Error)

Application.Exit()

End If
--
Gerry O'Brien
Visual Developer .NET MVP

"carr4895" <CA******@YAHOO.COM> wrote in message
news:f8**************************@posting.google.c om...
Hello.
I was wondering if someone could help me too with a login form. Upon
startup, I have to display a password screen and it should accept a
user name and password. User name can be anything non-blank. If
there is no user name, an appropriate error message must be displayed.
All of the following passwords are valid IT160, VB2Manager, BackDoor.
No other password is valid. It must allow the user to enter the
password in any case. If an invalid password is enterd, i need to
display an appropriate message. If no password is entered or if the
password is incorrect after three tries, display a sorry message and
exit the program. I am using VB.Net and it is an MDI form. Ineed to
display the password screen then the splash screen and the the parent
form. Please help. I am so confused. Thanks

Nov 20 '05 #3

P: n/a
Hehe, everyone thought it... but you said it. nice. =)
"Tom Leylan" <ge*@iamtiredofspam.com> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl...
You forgot to include the e-mail address of your instructor... or will you
handle the part where you turn it in for a grade?

Is there any part of the lesson which you are not confused about? We could build from there unless you just want the A+ and prefer to skip the coding
part of things?

"carr4895" <CA******@YAHOO.COM> wrote...
Hello.
I was wondering if someone could help me too with a login form. Upon
startup, I have to display a password screen and it should accept a
user name and password. User name can be anything non-blank. If
there is no user name, an appropriate error message must be displayed.
All of the following passwords are valid IT160, VB2Manager, BackDoor.
No other password is valid. It must allow the user to enter the
password in any case. If an invalid password is enterd, i need to
display an appropriate message. If no password is entered or if the
password is incorrect after three tries, display a sorry message and
exit the program. I am using VB.Net and it is an MDI form. Ineed to
display the password screen then the splash screen and the the parent
form. Please help. I am so confused. Thanks


Nov 20 '05 #4

P: n/a
Gerry,

* "Gerry O'Brien [MVP]" <gk******@hotmail.com> scripsit:
If UCase(strPassword) = "IT160" Or UCase(strPassword) = "VB2MANAGER" Or
UCase(strPassword) = "BACKDOOR" Then


I prefer (untested):

\\\
Select Case UCase(strPassword)
Case "IT160", "VB2MANAGER", "BACKDOOR"
...
Case Else
...
End Select
///

:-)

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Nov 20 '05 #5

P: n/a
I prefer an array of strings just in case the professor asks for a 4th, 5th
or 6th password.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote...
Gerry,

* "Gerry O'Brien [MVP]" <gk******@hotmail.com> scripsit:
If UCase(strPassword) = "IT160" Or UCase(strPassword) = "VB2MANAGER" Or
UCase(strPassword) = "BACKDOOR" Then


I prefer (untested):

\\\
Select Case UCase(strPassword)
Case "IT160", "VB2MANAGER", "BACKDOOR"
...
Case Else
...
End Select
///

:-)

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>

Nov 20 '05 #6

P: n/a
The clue (and other students take note) is that the specs are too exact,
right down to the passwords no less... so that would be uhhh the three he
decided to use, the three the CEO of the company he works for wanted or let
me guess... exactly what it says on the photocopied homework assignment?

If somebody posted an example with "PASSWORD1" there would be translation
work to be done and the huge possibility of it being handed in verbatim
yielding only a C+ for effort.

"CJ Taylor" <no****@blowgoats.com> wrote...
Hehe, everyone thought it... but you said it. nice. =)

Nov 20 '05 #7

P: n/a
Cor
Hi Tom,
I prefer an array of strings just in case the professor asks for a 4th, 5th or 6th password.


I would type almost this when I saw your message

Greath post about the lessons.

:-)

Cor
Nov 20 '05 #8

P: n/a
Tom,

* "Tom Leylan" <ge*@iamtiredofspam.com> scripsit:
I prefer an array of strings just in case the professor asks for a 4th, 5th
or 6th password.


:-)))

That's what I prefer too. I only wanted to show an alternative way to
write the code.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Website Address Changed!
Nov 20 '05 #9

P: n/a
You guys are nasty...
I wouldn't want to have pigtails if you fellas were sitting behind
me...
I'd have to run home crying every day!

;)

If you decide to sit your MCP Carr, you might also like to check out
the BigFoot, "uh-hem", exam guides, "uh-hem".

hth
Richard
Nov 20 '05 #10

P: n/a
Well!!! :-))
--
Gerry O'Brien
Visual Developer .NET MVP

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c2*************@ID-208219.news.uni-berlin.de...
Gerry,

* "Gerry O'Brien [MVP]" <gk******@hotmail.com> scripsit:
If UCase(strPassword) = "IT160" Or UCase(strPassword) = "VB2MANAGER" Or
UCase(strPassword) = "BACKDOOR" Then


I prefer (untested):

\\\
Select Case UCase(strPassword)
Case "IT160", "VB2MANAGER", "BACKDOOR"
...
Case Else
...
End Select
///

:-)

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>

Nov 20 '05 #11

P: n/a
Better yet, let's use a collection of some sort like a hash table so we can
better manipulate them.

--
Gerry O'Brien
Visual Developer .NET MVP

"Tom Leylan" <ge*@iamtiredofspam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I prefer an array of strings just in case the professor asks for a 4th, 5th or 6th password.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote...
Gerry,

* "Gerry O'Brien [MVP]" <gk******@hotmail.com> scripsit:
If UCase(strPassword) = "IT160" Or UCase(strPassword) = "VB2MANAGER" Or UCase(strPassword) = "BACKDOOR" Then


I prefer (untested):

\\\
Select Case UCase(strPassword)
Case "IT160", "VB2MANAGER", "BACKDOOR"
...
Case Else
...
End Select
///

:-)

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>


Nov 20 '05 #12

P: n/a
Well. I am so sorry. I was just having trouble with the password
part of it. I thought you people could help me. I didn't mean to ask
for the whole thing. I am not a guy either so there. Thanks for
helping and I am sorry about the whole thing.

"Gerry O'Brien [MVP]" <gk******@hotmail.com> wrote in message news:<#T**************@TK2MSFTNGP09.phx.gbl>...
Well!!! :-))
--
Gerry O'Brien
Visual Developer .NET MVP

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c2*************@ID-208219.news.uni-berlin.de...
Gerry,

* "Gerry O'Brien [MVP]" <gk******@hotmail.com> scripsit:
If UCase(strPassword) = "IT160" Or UCase(strPassword) = "VB2MANAGER" Or
UCase(strPassword) = "BACKDOOR" Then


I prefer (untested):

\\\
Select Case UCase(strPassword)
Case "IT160", "VB2MANAGER", "BACKDOOR"
...
Case Else
...
End Select
///

:-)

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>

Nov 20 '05 #13

P: n/a
I don't know if you're still following along so I'll post it for your and/or
for others who may run across it...

It's my opinion of course but nobody here doesn't want to help. Similarly
nobody really wants to do you homework for you. Learning things you don't
know (after all) is the reason you are being asked to do the homework.
Girl, guy or somewhere in between we'd like the grade just as much as you
but we won't get it you will for all the work that somebody here puts into
your homework assignment.

As an alternative you might try posting what you've done so far. Then
somebody is bound to suggest an alternative or post a few lines of code to
get you past a tough spot. As you will (make that "should") notice you
didn't post the few lines of code that you were stuck on, you posted your
assignment with nary a line of code in sight.

Want a suggestion? Stick around and try to answer other people's questions.
That way you learn new stuff and you help others. It also gives you some
insight into the kinds of problems people run into and the type of things
you will be expected to know if you ever decide to get into software
development professionally.

Tom
"carr4895" <CA******@YAHOO.COM> wrote in message
news:f8**************************@posting.google.c om...
Well. I am so sorry. I was just having trouble with the password
part of it. I thought you people could help me. I didn't mean to ask
for the whole thing. I am not a guy either so there. Thanks for
helping and I am sorry about the whole thing.

"Gerry O'Brien [MVP]" <gk******@hotmail.com> wrote in message

news:<#T**************@TK2MSFTNGP09.phx.gbl>...
Well!!! :-))
--
Gerry O'Brien
Visual Developer .NET MVP

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c2*************@ID-208219.news.uni-berlin.de...
Gerry,

* "Gerry O'Brien [MVP]" <gk******@hotmail.com> scripsit:
> If UCase(strPassword) = "IT160" Or UCase(strPassword) = "VB2MANAGER" Or > UCase(strPassword) = "BACKDOOR" Then

I prefer (untested):

\\\
Select Case UCase(strPassword)
Case "IT160", "VB2MANAGER", "BACKDOOR"
...
Case Else
...
End Select
///

:-)

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>

Nov 20 '05 #14

P: n/a
I just needed help. I am so sorry for asking and for putting the
whole thing in. I am usually good at this kind of stuff but the
password part was hard for me. That is what i was having trouble
with. So don't critize mem. I am a good person. And I am not a guy
either. I was having trouble with cut, copy, and paste too but I am
not going to ask for any help. I was also going to have you look at
my slot machine game because i thought it would be cool for you people
to see it, but not anymore. Here is what I had before I even posted
the question.
Thanks
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
Dim strCapPass As String
'This line makes sure a User Name is entered.
'If not, it displays a message and exits the procedure.
If txtUserName.Text = "" Then
Unload.Me()
Else
MessageBox.Show("Must Enter User Name!", "Login")
txtUserName.Focus()
End If
'This line changes this text to capital letters
strCapPass = UCase(txtPassword.Text)
'This select statement checks the password
Select Case strCapPass
Case "IT160"
Unload(Me)
Case "VB2MANAGER"
Unload(Me)
Case "BACKDOOR"
Unload(Me)
Case Else
'Count how many times there is an invalid password
mintInvalPass = mintInvalPass + 1
'if there is less than three display the message
If mintInvalPass < 3 Then
MessageBox.Show("Invalid Password, try again!",
"Login")
'This line set the cursor in the txtPassword
textbox
txtPassword.Focus()
Else
'if there is more than three display sorry message
MessageBox.Show("Sorry, You Only get Three Trys!",
"Login")
End
End If
End Select
End Sub
I just had trouble converting it to VB.NET. Oh well.
Bye.
Then unload me part was confusing me.

"Tom Leylan" <ge*@iamtiredofspam.com> wrote in message news:<e4**************@TK2MSFTNGP10.phx.gbl>...
You forgot to include the e-mail address of your instructor... or will you
handle the part where you turn it in for a grade?

Is there any part of the lesson which you are not confused about? We could
build from there unless you just want the A+ and prefer to skip the coding
part of things?

"carr4895" <CA******@YAHOO.COM> wrote...
Hello.
I was wondering if someone could help me too with a login form. Upon
startup, I have to display a password screen and it should accept a
user name and password. User name can be anything non-blank. If
there is no user name, an appropriate error message must be displayed.
All of the following passwords are valid IT160, VB2Manager, BackDoor.
No other password is valid. It must allow the user to enter the
password in any case. If an invalid password is enterd, i need to
display an appropriate message. If no password is entered or if the
password is incorrect after three tries, display a sorry message and
exit the program. I am using VB.Net and it is an MDI form. Ineed to
display the password screen then the splash screen and the the parent
form. Please help. I am so confused. Thanks

Nov 20 '05 #15

P: n/a
There is probably little reason to continue the conversation but I'll take
one more stab at it.
I am a good person. Nobody posted "you're a bad person."
And I am not a guy either. Nobody suggested that you were and nobody cares if you are or aren't.
I was having trouble with cut, copy, and paste too but I am
not going to ask for any help.
That's your choice... I surely don't understand your decision but it is your
decision to make.
I was also going to have you look at my slot machine game because
i thought it would be cool for you people to see it, but not anymore.
Trust me we can write a slot machine program also. If not individually
certainly as a group :-)
Here is what I had before I even posted
You should have considered posting your code earlier then we could have made
suggestions for improvement. Please note (you seem intent on ignoring this)
you simply posted the "specs" which clearly was a homework assignment.
Personally I would give you a C as the code probably works. It is far from
elegant but you have to start somewhere.

Best of luck to you... the offer for you to post "answers" as a way to learn
remains open BTW.
"carr4895" <CA******@YAHOO.COM> wrote in message
news:f8**************************@posting.google.c om... I just needed help. I am so sorry for asking and for putting the
whole thing in. I am usually good at this kind of stuff but the
password part was hard for me. That is what i was having trouble
with. So don't critize mem. I am a good person. And I am not a guy
either. I was having trouble with cut, copy, and paste too but I am
not going to ask for any help. I was also going to have you look at
my slot machine game because i thought it would be cool for you people
to see it, but not anymore. Here is what I had before I even posted
the question.
Thanks
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
Dim strCapPass As String
'This line makes sure a User Name is entered.
'If not, it displays a message and exits the procedure.
If txtUserName.Text = "" Then
Unload.Me()
Else
MessageBox.Show("Must Enter User Name!", "Login")
txtUserName.Focus()
End If
'This line changes this text to capital letters
strCapPass = UCase(txtPassword.Text)
'This select statement checks the password
Select Case strCapPass
Case "IT160"
Unload(Me)
Case "VB2MANAGER"
Unload(Me)
Case "BACKDOOR"
Unload(Me)
Case Else
'Count how many times there is an invalid password
mintInvalPass = mintInvalPass + 1
'if there is less than three display the message
If mintInvalPass < 3 Then
MessageBox.Show("Invalid Password, try again!",
"Login")
'This line set the cursor in the txtPassword
textbox
txtPassword.Focus()
Else
'if there is more than three display sorry message
MessageBox.Show("Sorry, You Only get Three Trys!",
"Login")
End
End If
End Select
End Sub
I just had trouble converting it to VB.NET. Oh well.
Bye.
Then unload me part was confusing me.

"Tom Leylan" <ge*@iamtiredofspam.com> wrote in message

news:<e4**************@TK2MSFTNGP10.phx.gbl>...
You forgot to include the e-mail address of your instructor... or will you handle the part where you turn it in for a grade?

Is there any part of the lesson which you are not confused about? We could build from there unless you just want the A+ and prefer to skip the coding part of things?

"carr4895" <CA******@YAHOO.COM> wrote...
Hello.
I was wondering if someone could help me too with a login form. Upon
startup, I have to display a password screen and it should accept a
user name and password. User name can be anything non-blank. If
there is no user name, an appropriate error message must be displayed.
All of the following passwords are valid IT160, VB2Manager, BackDoor.
No other password is valid. It must allow the user to enter the
password in any case. If an invalid password is enterd, i need to
display an appropriate message. If no password is entered or if the
password is incorrect after three tries, display a sorry message and
exit the program. I am using VB.Net and it is an MDI form. Ineed to
display the password screen then the splash screen and the the parent
form. Please help. I am so confused. Thanks

Nov 20 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.