[thelist] ASP If statement gone nuts

Gary McPherson genyus at ingenyus.net
Fri Aug 1 20:51:39 CDT 2003


thelist-bounces at lists.evolt.org wrote:
> Below is some code from my calendar program. I also attached
> it, but don't know it the attachment will go thru the list. I
> took out everything I could to get it down to the errant
> statements. You can see my calendar at
> www.whitelightening.net/buzzell/calendar.asp
> 
> Seems quite crazy to me.
> 
> I originally wrote it as a simple IF statement:
> 
>     if currentMonth > qsmonth then
>          qyear = qyear+1
>     end if
> 
> This calendar should work for the year ahead of us.
> Today it is August 2003. SO... if someone wants to look at
> September, October or November, it is presumed they are still
> looking at 2003. If someone wants to look at January, it is
> presumed they want January, 2004.
> 
> Therefore, if currentMonth (8 for August) is greater than
> requested month (1 for January), add 2003 + 1 and get 2004.
> 
> Kindergarten level logic, if you ask me. So, where am I going
> wrong???? 
> 
> No matter what months I requested, this logic never gets
> executed. When I switched it ("<"), it ALWAYS executes, and I get
> 2004 no matter what. 
> 
> You can see in my logic there are displays everywhere. It
> doesn't care what the values are. If I use ">" it ALWAYS
> finds the condition false. If I use "<". It always finds the logic
> true! 
> 
> I thought maybe my computer was broken, so I put it out on
> the web (see above url), to see how it ran under someone else's
> computer. No change. 
> 
> The HAS to be something very dumb and obviouis (to everyone else)
> wrong with my coding. 
> 
> Can somebody help?
> 
> thanks
> Laura

<snip>
> qsmonth=request.querystring("rqmonth")
> currentMonth=DatePart("m",date())
<snip>


Pulling the value from the querystring gives you a string representing a
numeric value. So you're comparing a string and a number, which results
in a constant result from your if query.

use qsmonth=cint(request.querystring("rqmonth") and all will be well in
the world once again.

Regards,

Gary




More information about the thelist mailing list