1. Registered User
Join Date
Jan 2004
Posts
27

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>```

2. Registered User
Join Date
Nov 2003
Location
Christchurch, New Zealand
Posts
1,619
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.

3. Registered User
Join Date
Jan 2004
Posts
27
Sorry, but what do you mean by I haven't "defined time"?

4. Registered User
Join Date
Nov 2003
Location
Christchurch, New Zealand
Posts
1,619
Code:
```time = Request.Form("txtDuration")
amt = Request.Form("txtAmt")```
There is no txtDuration to request and no txtAmt to request....

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•