Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditionals on Variables

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
I fought with this for quite a while before getting it to work but now I want to know why it wouldn't work as it was!

This works:

[tt]AssignedPropertyID = rsAssignedProperties("UserID")
UserID = session("UserID")
If UserID=AssignedPropertyID Then . . .[/tt]

but this more direct method does not and in fact, seems to give results that are the opposite of what they should be. In other words, if I replace the &quot;=&quot; with &quot;<>&quot; the results were closer to what I wanted.

[tt]If session(&quot;UserID&quot;) = rsAssignedProperties(&quot;UserID&quot;) Then . . .[/tt]

Any ideas or advice for the next time? Thanks! Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
try this:

will show an error if neither of them exist though so if that is a possibility then you will need some extra conditional code to establish their presence

Code:
If CInt(session(&quot;UserID&quot;)) = CInt(rsAssignedProperties(&quot;UserID&quot;)) Then . . .
Tony
reddot.gif WIDTH=400 HEIGHT=2 VSPACE=3

 
Thanks, that's helpful, but actually it's working now. In some cases (when there is no match), one of them doesn't exist but still, if one exists and one doesn't, then it should not match yet it was saying that it did.

My main question is if there is some rule, written or otherwise, that says you have to create variables first before you can run a conditional on them? I've done it before without any problems.

What I want to know is why it wouldn't work before when the conditional was more direct. Even when I printed the values to the screen and they clearly matched, and had a text value after the &quot;then&quot; saying &quot;They Match&quot; and an &quot;else&quot; that said &quot;They Do Not Match,&quot; the results were backwards. When the same value was there after the two variables, it said &quot;They Do Not Match&quot; yet when they were clearly different (or when one was missing), it said &quot;They Match.&quot; I already checked to be sure that there were no leading or trailing blank spaces that would make them APPEAR to match when they did not, but there were none. Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top