If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Overflow error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-04, 15:16
lklegend lklegend is offline
Registered User
 
Join Date: Jan 2004
Posts: 27
Overflow error

I want to allow the user to enter duration & amount of loan & then display the amount of the monthly & weekly instalements in textboxes. However I am getting an 'Overflow' error.

Code:
<%
dim time, amt, total, int, intTotal, finalTotal, month, monthly, week, weekly
time = Request.Form("txtDuration")
amt = Request.Form("txtAmt")
int = 0.08

if CCur(time) = 1 then
	month = 12
	week = 52
ElseIf CCur(time) = 2 then
	month = 24
	week = 104
End If

intTotal = (CCur(amt) * CCur(int))
total = (CCur(intTotal) + CCur(amt))

monthly = (CCur(total) / CCur(month))
weekly = (CCur(total) / CCur(week))
%>

<form action=# method="POST">
<table align=center border=0 width="394" rules="none">
	<tr>
		<th align=center width="194">Monthly Repayments</th>
		<th align=center width="194">Weekly Repayments</th>
	</tr>
	<tr>
		<td align=center width="194"><input type="text" name="txtMonthly" 
				value="<%Response.Write(monthly)%>"> </td>
		<td align=center width="194"><input type="text" name="txtWeekly" 
				value="<%Response.Write(weekly)%>"> </td>
	</tr>
</table>
</form>
Help please......thanks
Reply With Quote
  #2 (permalink)  
Old 03-03-04, 20:14
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
OKie,.. first question, why are you converting everything into a currency?? the month and week variables should be ints.

Your overflow is occuring because your converting (or your calculation) is coming up with an invalid casting... eg. 123456789012345678 is too much for an int value.

You should be doing your calculations on something else like a double and then converting the result of the calculation to a currency.

Acutally your overflow is coming because you haven't defined time (edit: the same goes for amt). You are requesting it but it doesn't exist in your form. So you week and month variables are null. When you convert null to a currency it will overflow (a bit of a guess here).

Having said that, all the other stuff written above still applies.
Reply With Quote
  #3 (permalink)  
Old 03-06-04, 07:46
lklegend lklegend is offline
Registered User
 
Join Date: Jan 2004
Posts: 27
Sorry, but what do you mean by I haven't "defined time"?
Reply With Quote
  #4 (permalink)  
Old 03-07-04, 21:17
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Code:
time = Request.Form("txtDuration")
amt = Request.Form("txtAmt")
There is no txtDuration to request and no txtAmt to request....
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On