Problem with string comparisons

# Thread: Problem with string comparisons

1. Senior Member
Join Date
Dec 1969
Posts
175

## Problem with string comparisons

Can someone pls help me take a look at whether there is anything wrong with my if statement?Cos i didnt get the result i want if i test the two conditions together.If i test them individually, it works.<BR><BR>&#060;coding&#062;<BR>if RS("Description") &#060;&#062; "Others" OR RS("Description") &#060;&#062; "Ops-Delete TRXs" then<BR> &#039;Do some task<BR>end if<BR>&#060;/coding&#062;

2. Senior Member
Join Date
Dec 1969
Posts
19,082

## RE: Problem with string comparisons

I think you want an AND instead of an OR. that will always come out true, because they can&#039;t be two things at once.

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Think about it for a second...

Let&#039;s say that RS("Description") is "Others".<BR><BR>So the first comparsion is *false*: it is NOT &#060;&#062; to "Others".<BR><BR>But obviously the second comparison is *true*: "Others" is certainly &#060;&#062; "Ops-Delete TRXs".<BR><BR>So you have just done<BR> If False Or True Then<BR>which of course simply becomes<BR> If True Then<BR><BR>**********<BR><BR>Now consider:<BR><BR>Let&#039;s say that RS("Description") is "Ops-Delete TRXs".<BR><BR>So the first comparsion is *true*: "Ops-Delete TRXs" is certainly &#060;&#062; to "Others".<BR><BR>But obviously the second comparison is *false*: "Ops-Delete TRXs" is the same as "Ops-Delete TRXs".<BR><BR>So you have just done<BR> If True Or False Then<BR>which of course simply becomes<BR> If True Then<BR><BR>**********************<BR><BR>Now consider:<BR><BR>Let&#039;s say that RS("Description") is "ZAMBONIS!".<BR><BR>So the first comparsion is *true*: "ZAMBONIS!" is certainly &#060;&#062; to "Others".<BR><BR>And similarly the second comparison is *true*: "ZAMBONIS!" is certainly &#060;&#062; to "Ops-Delete TRXs".<BR><BR>So you have just done<BR> If True Or True Then<BR>which of course simply becomes<BR> If True Then<BR><BR>*******************<BR><BR>May I hesitantly ask how you ever expected to ever have anything happen except<BR> &#039; Do some task<BR>???<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Awww...you're no fun...<eom>

.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•