I am a VB.NET newbie used to VBA. I am trying to figure out how to compare a variable to the value input into a textbox.
I tried declaring the variable and setting it's value, and used nested If/Then/Else statements to compare the textbox values to the variable. Even when the proper values are input, it still evaluates to fail.
Below is the code that I have written so far:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strUsername As String = "me"
Dim strPassword As String = "me2"
shtAttempts = shtAttempts + 1
If txtUsername Is strUsername Then
If txtPassword Is strPassword Then
MessageBox.Show("Access Granted!!")
End If
Else
If shtAttempts = 3 Then
MessageBox.Show("ACCESS DENIED!!!!!!!!!!!!!!")
Application.Exit()
Else
MessageBox.Show("The User ID / Password combination you entered is incorrect. You have a total of 3 chances to enter the proper information before being locked out.]")
End If
End If
End Sub
Clint Galliano
Halliburton Energy Services
BAROID PSL
"Done ONCE, Done RIGHT!"
I tried declaring the variable and setting it's value, and used nested If/Then/Else statements to compare the textbox values to the variable. Even when the proper values are input, it still evaluates to fail.
Below is the code that I have written so far:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strUsername As String = "me"
Dim strPassword As String = "me2"
shtAttempts = shtAttempts + 1
If txtUsername Is strUsername Then
If txtPassword Is strPassword Then
MessageBox.Show("Access Granted!!")
End If
Else
If shtAttempts = 3 Then
MessageBox.Show("ACCESS DENIED!!!!!!!!!!!!!!")
Application.Exit()
Else
MessageBox.Show("The User ID / Password combination you entered is incorrect. You have a total of 3 chances to enter the proper information before being locked out.]")
End If
End If
End Sub
Clint Galliano
Halliburton Energy Services
BAROID PSL
"Done ONCE, Done RIGHT!"