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

Math Problem

Status
Not open for further replies.

disord3r

Programmer
Apr 12, 2002
189
US
I'm probably just blind, but, here's the setup.

Paging through a recordset. Need to print only the records where the value of "total" is greater than the value of "notices". "total" comes from the recordset, and "notices" is from an HTML form. As such, the value of "total" will vary, while the value of "notices" will stay the same. Here's the code, pretty straight-forward:

while not RS.EOF
total = rs("total")
Response.Write total & ", " & notices

if total > notices then
Response.Write &quot; yep<BR>&quot;
else
Response.Write &quot; nope<BR>&quot;
end if

RS.MoveNext
wend

Here's an excerpt of the output:

...
1, 6 nope
1, 6 nope
1, 6 nope
1, 6 nope
7, 6 nope
...

&quot;7, 6 nope&quot;??? Last I checked, 7 was greater than 6. :)

Any advice is appreciated.
 
You might want to ensure that total and notices are of the same type when you compare them. Convert them using CInt or CDbl or CLng, depending on the type of data. So, assuming that they should both be int type, try:

if CInt(total) > CInt(notices) then
Response.Write &quot; yep<BR>&quot;
else
Response.Write &quot; nope<BR>&quot;
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top