Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 04-15-2008, 12:18 PM   #1
Daemon Poster
 
jo5h's Avatar
 
Join Date: Aug 2006
Posts: 1,030
Default Visual Basic (Microsoft Studio 2005) Help (Loops)

In my visual Basic programming class we were given an assignment to create an application that checks the password at sign-on time (when the application starts). The application will display an input box requesting a password. If the password is correct, it will display the form (me.show) If if the password is incorrect a message box will display "Re-enter Password", if the password is incorrect 3 times a message will display " contact your administrator" then will exit the application. Now my question is When the password is correct It has to display the form. I have everything else working just not the form display. Here is my code.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Variables
Dim n As Integer
Dim strpassword As String = "begin"
n = 0


'3 chances to get the password right

Do Until n = 3
strpassword = InputBox("Please enter your password", )

'IF the password is correct it will display vb is great

If strpassword = "begin" Then
Me.Show()
Else
MessageBox.Show("Re-Enter Password", "Incorrect Password", MessageBoxButtons.OK)
n = n + 1
End If
Loop

'If n = 3 the program will close

If n = 3 Then
MessageBox.Show("Invalid Password...Contact your Administrator", "Incorrect Password", MessageBoxButtons.OK, MessageBoxIcon.Stop)
End
End If
End Sub

So i was wondering if anyone here could point me in the direction of what im doing wrong.. feel free to edit the code.
__________________

__________________
AMD 64 X2 Dual Core 3800+
Asus M2N-SLI Deluxe
Corsair CM2 X 512 x 2 A-6400
Nvidia 7600 GS 256 MB PCI-E 16x
jo5h is offline   Reply With Quote
Old 04-15-2008, 04:05 PM   #2
Site Team
 
celegorm's Avatar
 
Join Date: Sep 2006
Posts: 10,713
Send a message via AIM to celegorm
Default Re: Visual Basic (Microsoft Studio 2005) Help (Loops)

what is the name of the form itself? If it's not "ME", then try frmform.Show()

Also, the second if statement should be before "loop"
__________________

__________________
"as a fanboy i refuse to admit it and will pull countless things out of my butt to disprove it"

Team Thelegorm! Total Kills: 21 (i iz in uor profile, editsing your sigz)
celegorm is offline   Reply With Quote
Old 04-15-2008, 05:09 PM   #3
Guru
 
JogaBonito1502's Avatar
 
Join Date: Jan 2008
Location: U.S.
Posts: 7,841
Default Re: Visual Basic (Microsoft Studio 2005) Help (Loops)

Celegorm, "me" can always be used. It refers to the current object. I c# I believe the keyword is "this". But yeah, "me" should work.
JogaBonito1502 is offline   Reply With Quote
Old 04-16-2008, 04:20 PM   #4
Site Team
 
celegorm's Avatar
 
Join Date: Sep 2006
Posts: 10,713
Send a message via AIM to celegorm
Default Re: Visual Basic (Microsoft Studio 2005) Help (Loops)

Quote:
Originally Posted by JogaBonito1502 View Post
Celegorm, "me" can always be used. It refers to the current object. I c# I believe the keyword is "this". But yeah, "me" should work.
Really? Never used "me" to load a form so I didn't make the connection.
__________________
"as a fanboy i refuse to admit it and will pull countless things out of my butt to disprove it"

Team Thelegorm! Total Kills: 21 (i iz in uor profile, editsing your sigz)
celegorm is offline   Reply With Quote
Old 04-16-2008, 05:16 PM   #5
Guru
 
JogaBonito1502's Avatar
 
Join Date: Jan 2008
Location: U.S.
Posts: 7,841
Default Re: Visual Basic (Microsoft Studio 2005) Help (Loops)

Well, from what I see he's not trying to load the form. You can't use a message box with an unloaded form. The form is loaded it is just invisible.
JogaBonito1502 is offline   Reply With Quote
Old 04-17-2008, 10:08 AM   #6
Daemon Poster
 
jo5h's Avatar
 
Join Date: Aug 2006
Posts: 1,030
Default Re: Visual Basic (Microsoft Studio 2005) Help (Loops)

I figured it out

after the password is entered correctly

me.show (which is the form)
exit sub
__________________

__________________
AMD 64 X2 Dual Core 3800+
Asus M2N-SLI Deluxe
Corsair CM2 X 512 x 2 A-6400
Nvidia 7600 GS 256 MB PCI-E 16x
jo5h is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 01:37 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0