IF Statement question

TyB

Well-known member
Joined
May 14, 2009
Messages
102
Programming Experience
3-5
Hello all,

Trying to get a IF statement working.

strUSER = "Test1"

This works.... The exception does not fire
VB.NET:
ElseIf Not strUSER Like "Test1" Then
                Throw New ArgumentException("Error")
            End If

This does not.....The exception does fire

strUSER = "Test1"

VB.NET:
ElseIf Not strUSER Like "Test2" Or Not strUSER Like "Test1" Then
                Throw New ArgumentException("Error")
            End If

I need the second one to work as well. The exception should not fire.
Why?

Thanks,

Ty
 
Hello all,

Trying to get a IF statement working.

strUSER = "Test1"

This works.... The exception does not fire
VB.NET:
ElseIf Not strUSER Like "Test1" Then
                Throw New ArgumentException("Error")
            End If

This does not.....The exception does fire

strUSER = "Test1"

VB.NET:
ElseIf Not strUSER Like "Test2" Or Not strUSER Like "Test1" Then
                Throw New ArgumentException("Error")
            End If

I need the second one to work as well. The exception should not fire.
Why?

Thanks,

Ty
Have you tried:
VB.NET:
ElseIf Not strUSER Like "Test2" AndAlso Not strUSER Like "Test1" Then
                Throw New ArgumentException("Error")
            End If
?
 
Back
Top