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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If then not working

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
This seems like it should woork but is not:

I am finding two variable, say var1 and var 2, I then do:

...if var1 = var2 Then%>
...display a certain image...
<%Else%>
...display another image...
<%End If....

it only displays one image no matter what. I know they variables are getting created/grabbed correctly. When I change the = to <> it shows the other image, so it is working in some sense but not as it should.

Does anything leap out as being wrong?
 
Do a response.write and write the values of the variables to the web page. I am guessing that if the code is right then the variables must be the issue. You may not be getting the results you think you are.
 
The variables are correct - that's what is throwing me off
 
Are the variables floating point ie, 9.25 = 9.25
This will sometimes cause a problem.

If so, simply put Round(var1,2) = Round(var2,2) instead

-Bo -Adam T. Courtney
Stratagem, Inc.
 
var1 is simply an integer grabbed via a request.QueryString and var 2 is 0 and then is changed via a while loop - here it is at a greater scale:

<%
Dim var2
var 2 = 0;
While finder > 0
If var1 = var2 Then%>
...display a certain image...
<%Else%>
...display another image...
<%End If
finder = finder+1
var2 = var2+10
Wend
%>

Finder is a variable developed based on a number of records in a db

 
So you'll only expecting a match if var1 = a multiple of 10, is that correct?
 
Well, with the current code that's the only time you're going to get a match and therefore successfully &quot;display a certain image&quot; as opposed to &quot;display another image&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top