Visual Basic Login Form Problems...

April 9, 2011 at 20:20:49
Specs: Windows 7 Premium Home, Core i5 2.4Ghz RAM 4Gb
I am trying to make a login form. But whenever i click OK after keying in, an error will come up:
Compile Error: Block if without end if
I just cant seem to get it work...no matter how i twist the codes!!!

Here's what my scripts look like:

Private Sub cmdOK_Click()
If txtUser.Text = txtUser.Tag Then
If txtPass.Text = txtPass.Tag Then
MsgBox "Successfully logged in. Welcome back.", vbExclamation = vbOKOnly, "Login Successful"
frmCalculator.Show
Unload Me
End If

Else
If txtUser.Text <> txtUser.Tag And txtPass.Text <> txtPass.Tag Then
MsgBox "Username and Password mismatched. Please revise entry. Login denied.", vbCritical = vbOKOnly, "Incorrect Entry"
txtUser.SetFocus
End If

If txtUser.Text <> "" And txtPass.Text <> "" then
cmdOK.enabled = False
else
cmdOK.enabled = True
End if
End Sub

Your help will greatly be appreciated!!


See More: Visual Basic Login Form Problems...

Report •

#1
April 9, 2011 at 20:22:55
for programming you should post here: http://www.computing.net/forum/prog...

Report •

#2
April 9, 2011 at 21:15:01
Compile Error: Block if without end if
This is true. I count 4 If's, but only 3 End If's. I imagine you could get away with adding an, "End If" just before the, "End Sub."

How To Ask Questions The Smart Way


Report •

#3
April 11, 2011 at 03:28:45
Oh right! Somewhat i didnt see that! Thanks for pointing that out for me!
I am new to visual basic thats why.
Anyways, thanks again Razor2.3!

Report •
Related Solutions


Ask Question