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

= operator producing strange results

Status
Not open for further replies.

JonathanG6SWJ

Programmer
Jan 18, 2005
39
GB
Hi Guys

This has to be something so incredibly simple, I'm sure I'm going to be embarrassed by the answer.

Code:
if intpage =9 then
Response.Write "Confirmed intpage= 9 " 
End If
>>>>>Result true Response.Write outputs text

if intpagecount =9 then
Response.Write"intPageCountpage= 9"
End If
>>>>>Result true Response.Write outputs text
		 
if intpage=intpagecount then
Response.Write "Sucess intpage = intPageCount !They are equal "
End If
>>>>>Result not true No Ouput Text.

(nb. >>>>> is the result I get & not part of code)

Both int's are numerical (or at least if I do +1 they increment by one in value

Many thanks in advance
Jonathan
 
What happens if you do:

If (cInt(intpage) = cInt(intpagecount)) Then
 
It does indeed sound like ASP considers one of your values to not be an int. Adding 1 to it will, indeed, convert it to an int (the processor is smart enough), but comparing them doesn't necessarily provide instant conversion. You're probably asking it to compare "9" to 9.

Go with Sheco's suggestion, If CInt(intpage) = CInt(intpagecount) Then
 
Question guys,

As Chris, his code works fine as-is on my server. I perswonally use the CInt or CStr to verify but why would it work on ours and not his? Curious minds wanna know..

BSL


 
Probably because he doesn't have the same source for his values that you do. His was likely hardcoded in, while I am betting your two values came from a database.

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top