Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Help with IF THEN ELSE

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,50548
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Help with IF THEN ELSE
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Help with IF THEN ELSE - 8/9/2007 2:35:37 PM   
  Highwayman

 

Posts: 2
Score: 0
Joined: 8/9/2007
Status: offline
I'm fairly new to VBScript and I've written an asp page to dynamically create content from a text file.

Everything was running smoothly, and I had a statement near the bottom of the page in the HTML body to evaluate a condition.

If the value of "act_today" is less than that of "dayrun" write the value of "act_today" in red, else write it in black.

<td align="right"><% if (act_today)<(dayrun) then response.write("<font color='red'>" & (act_today)) else response.write(act_today) end if %></td>

This worked correctly and changed the colour of the output accordingly.

However, one of my calculations further up the script could have resulted in an error where the script would try to divide another variable by 0, so I put in the following statement to evaluate this condition.

If the value of "remain" is greater than 0, "dayrun" is the rounded result of "to_go" divided by "remain", else dayrun is equal to to_go

if (remain)>0 then dayrun=(Round((to_go/remain), 0)) else dayrun=to_go

This however has broken the 1st statement, and it always evaluates the condition as false...

anyone have any pointers or tips... I havent been able to solve this in a few days so far, and it's doing my head in to say the least

 
 
Post #: 1
 
 RE: Help with IF THEN ELSE - 8/9/2007 3:41:36 PM   
  Highwayman

 

Posts: 2
Score: 0
Joined: 8/9/2007
Status: offline
I had a LONG look through the forums and found that converting the variable to the Double subtype fixed the problem.

The 1st statement now reads...

<td align="right"><% if (CDbl(act_today))<(CDbl(dayrun)) then response.write("<font color='red'>" & (act_today)) else response.write(act_today) end if %></td>

Still not sure why adding the other evaluation changed the way it behaved... If somebody has the time to explain it, I'd be greatful

(in reply to Highwayman)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Help with IF THEN ELSE Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts