Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 4th, 2006, 11:55 AM
Registered User
 
Join Date: Dec 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unsolved OverFlow Error

Hi everyone. This is my first time posting anything here. I am new to script too. Currently I work on an loan calculator. Seems like everything is fine except seeing an Microsoft VBScript runtime error '800a0006' “Overflow” error on the initial page load. However the calculator works fine. The error was caused by the Formula:

Tax = Tax/100
APRRate = IntRate/100
Rate = APRRate/12

Total = Round((Price-Rebate-DownPay) * (1+Tax))

Term_Value = Round(Total*Rate/(1-(1+Rate)^(-Term)))

I tried to change Round to Clng, but nothing improved. base on this error, What action I should take to eliminate this error.

Thank you in advance for any suggestion.


 
Old December 4th, 2006, 12:36 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It would be helpful to know what values are actually contained in each of your variables.
Overflow occurs when you attempt to put a value into a variable that is too large for the variable.
It is unclear from your code how this could be happening.
However - you could get the Divide by Zero error easily enough.

The Clng would easily get the Overflow error in your scenario, but not the round - round accepts a huge floating point number that you are unlikely to be coming even close to with a loan calculator.

Woody Z http://www.learntoprogramnow.com
 
Old December 4th, 2006, 01:40 PM
Registered User
 
Join Date: Dec 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your quick response.
all value are come from the FORM. the more detail is below:
Dim Price,Rebate,DownPay,Tax,IntRate
Dim Total,Rate,TermP,APRRate

Price = Request("AutoPrice")
Rebate = Request("DRebate")
DownPay = Request("DownPayment")
Tax = Request("SaleTax")
IntRate = Request("InterestRate")

Tax = Tax/100
APRRate = IntRate/100
Rate = APRRate/12

Total = Round((Price-Rebate-DownPay) * (1+Tax))

dim Term_Value
    Term_Value = Round(Total*Rate/(1-(1+Rate)^(-Term)))

I already made sure no 0 value entered into the certain FORM area to avoid the dividing 0's issue. Couldn't figured out which part out of track.

 
Old December 4th, 2006, 01:57 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It would probably be a good thing to break down the values used in the Round call into their own variables so you can "response.write" the values out to see what values you are operating on.

dim varDividend
dim varDivisor
varDividend = Total*Rate
varDivisor = 1-(1+Rate)^(-Term)

You can then response.write these two values out to see if they are as expected. Hopefully, this will help narrow things down.

Another exercise is to attempt to cause an Overflow in a simple page with just the code you are experimenting with so you can see what conditions cause this error to be raised.

Woody Z http://www.learntoprogramnow.com
 
Old December 4th, 2006, 02:14 PM
Registered User
 
Join Date: Dec 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot. I will try the method you suggested.

 
Old December 4th, 2006, 07:16 PM
Registered User
 
Join Date: Dec 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your nicely help. Problem solved. I added a If condition to make sure that the varDivisor<>0, then the error disappeared.
Thank you once again.

 
Old December 4th, 2006, 07:45 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Excellent! Thanks for letting us know the solution, that is fantastic!


Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Arithmetic overflow error gregalb Reporting Services 1 June 24th, 2008 02:42 PM
Find with overflow error EricB123 Excel VBA 0 July 20th, 2007 10:34 AM
Odd arithmetic overflow error.... 7racer SQL Server 2000 4 May 12th, 2006 09:17 AM
Overflow Error mateenmohd Classic ASP Basics 4 July 5th, 2005 02:12 AM
can anybody tell why i am getting overflow error tulsi15 SQL Server 2000 1 December 15th, 2004 07:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.