Click here to Skip to main content
14,574,789 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi, can anyone please tell me why the code below does not read pass the (Me.Close()). Thanks in advance.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
v2

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100