Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, can anyone please tell me why the code below does not read pass the (Me.Close()). Thanks in advance.
VB
Private Sub btnALogIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnALogIn.Click
        If txtAUserName.Text = "" Then
            MsgBox("Please Enter An Administrator Username")
            txtAUserName.Focus()
        Else
            If txtAPassword.Text = "" Then
                MsgBox("Please Enter An Administrator Password")
                txtAPassword.Focus()
            Else
                If txtAUserName.Text = "me555" Then
                    If txtAPassword.Text = "9000" Then
                        SalesMainForm.Enabled = True
                        Me.Close()
                    Else
                        MsgBox("Access Denied. Please Check Your Administrator Username And/Or Password", MsgBoxStyle.Information)
                        txtAUserName.Text = ""
                        txtAPassword.Text = ""
                    End If
                End If
            End If
        End If
    End Sub
Posted

1 solution

In my opinion, you use a really bad approach.
To get there you need SIMULTANEOUSLY to have true
txtAUserName.Text = ""
      txtAUserName.Text = "me555"
      txtAPassword.Text = "" 
      txtAPassword.Text = "9000"


Every time you use txtXXX.Focus() program execution go out of your method since it meets "Else".

I think you should use embedded Validation events. Look here for example.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900