Not Equal Operator <>

Started by ktk, January 02, 2007, 05:44:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ktk

I was trying to use the relational operator <> in comparing a String variable and it does not seem to function.  When I turn on trace the results are listed below.

Spline$ = "Y"

If Spline$ <> "Y" OR Spline$ <> "y" Then GoTo EarlyOut   Test = True
And
If Spline$ = "Y" OR Spline$ = "y" Then GoTo EarlyOut       Test = True

I think that this had come up before but  I changed the test to work around the problem.   

dcadRob

#1
The problem is the use of the OR operator which returns TRUE if either side is TRUE :
For example, when Spline$="Y"
Spline$<>"Y" is FALSE
Spline$<>"y" is TRUE
So FALSE OR TRUE is TRUE

If you want to jump out based on Y/N answers, use the AND operator:

If Spline$<>"Y" AND Spline$<>"y" then ... TRUE when Spline$=something besides "Y" or "y"

If Spline$="Y" OR Spline$="y" then ... TRUE when Spline$="Y" or "y"

ktk

Thanks Prl that a form that will work.  If the <> is only for numbers it should be so noted in the docmuntation.  I use that form in VB so I just expected basic cad to accept it also.

dcadRob

There is nothing wrong with <>. It  works for numbers and strings.

ktk

Yes.  That code is so hard to follow I wrote it wrong. When I see what it should have been its obvious.

The forum is so great.  Years ago when I programed in a vacuum it would have been a long time ( if ever ) before I found out my problem.

Thanks