I had a problem with some code tonight that drove me crazy! It used to work, but now it doesn't!
I have a Method (Function) called IsValid, for example, that returns Boolean.
Public Function IsValid(TestText As String) As Boolean
If TestText = "Test" Then
Return True
Else
Return False
End If
End Function
I then had code that said:
If Not IsValid(TestText.Text) Then lblResults.Text = "Wrong"
All of the sudden it just quit working, so I stepped through it and it looked correct, but it kept going saying "Wrong", even if it was right!
So, I tried adding this line:
Dim CheckValid As Boolean = IsValid(TestText.Text)
CheckValid was returning correctly! So, I finally tried this:
If Not IsValid(TestText.Text) Then
lblResults.Text = "Wrong"
End If
For some reason, it required the If — Then to be on separate lines and that of course required the End If. Oh, well, it's a little more readable that way anyway, but still, it's just the point!