Reputation: 350
I have a string called str
and in my event it is equal to "Administrator" when I use the code:
Dim AdminSTR As String = "Administrator"
If str.ToString = AdminSTR Then
Home.CurrentUser.Text = "Current User: " & UsernameTextBox.Text
Home.CurrentUserSTR = UsernameTextBox.Text
Home.AccessLBL.Text = " | Level: " & str
Home.Show()
Else
ClientForm.Show()
End If
It directs me to me ClientForm
. While it should direct me to my Home
form. Why is this so?
Thanks
Upvotes: 0
Views: 79
Reputation: 350
I fixed it! I had a line of code which added a " " to the start of it to prevent it from being an empty value. Thanks to all that helped! Especially @TimSchmelter, for pointing out the cases and white-spaces! Voted up! :)
Upvotes: 0
Reputation: 460018
Just guessing, maybe it's "administrator" instead, .NET is case-sensitive by default. Or you have white-spaces at the beginning/end:
If "Administrator".Equals(str.Trim(), StringComparison.OrdinalIgnoreCase) Then
Home.CurrentUser.Text = "Current User: " & UsernameTextBox.Text
Home.CurrentUserSTR = UsernameTextBox.Text
Home.AccessLBL.Text = " | Level: " & str
Home.Show()
Else
ClientForm.Show()
End If
Upvotes: 4