Am I just being blind or does this if statement genuinely not do what it’s meant to?
Dim textSample as String = "F"
If Not textSample = "D" Or Not textSample = "E" Or Not textSample = "F" Then
MessageBox.Show("False")
End If
This displays the message box even though textSample is one of the letters. In my eyes that if statement should see that textSample is one of those letters and skip it, whereas if it was Z it would “Not” be equal to any of those and would therefore show the message box.
Why does it step into the if statement?
cond1 Or cond2 Or ... Or condnis true if and only if at least one of the given conditions are true. In your case it is always the case that at least one of the conditions is true (in fact at least two of the conditions will be true in each case). For example iftextSampleis"D"then the conditionNot textSample = "E"and the conditionNot textSample = "F"will be true. So the whole condition will be true.Long story short: Use And instead of Or.