<%@ LANGUAGE="VBScript" %> <%Option Explicit%> Loan Calculator <% 'Get Interest Rate dim rs, cn, aspInterest set cn = server.CreateObject("Adodb.Connection") set rs = server.CreateObject("Adodb.Recordset") cn.Open conn rs.open "Select * From tblInterest Where ID=1",cn aspInterest = rs.fields("Interest") rs.close cn.close set rs = nothing set cn = nothing ' calculating loan payments : ' ' formula is Pi / (q * (1 - (1 + (i / q))^(-nq) ' ' the variables are: ' ' P - The amount of the loan ' i - The interest expressed as a decimal (e.g. 8% is .08) ' n - The number of term units (e.g. number of years) ' q - The number of payments per term unit (e.g. 12 months) Dim aspResult, p, i, y, aspTotalVAT, aspVAT, aspEmail, aspPrincipal, aspID 'removed dim dp aspResult = "" aspVAT = "" aspTotalVAT = "" If Request.Form("cmdAgain") <> "" Then aspEmail = Request.form("aspEmail") aspPrincipal = "" end if If Request.Form("cmdSubmit") <> "" Then On Error Resume Next p = Request.Form("aspPrincipal") 'dp = Request.Form("aspDownPayment") i = aspInterest / 100 y = Request.Form("aspYears") aspResult = (p * i / (12 * (1 - (1 + (i / 12))^(-y*12)))) aspVAT = (aspResult / 100)*17.5 aspTotalVAT = aspResult + aspVAt aspResult = Round(aspResult, 2) aspVAT = Round(aspVAT, 2) aspTotalVAT = Round(aspTotalVAT, 2) aspEmail = Request.form("aspEmail") ' Submit to Database set cn = server.CreateObject("Adodb.Connection") set rs = server.CreateObject("Adodb.Recordset") cn.Open conn rs.open "Select * From tblCalc",cn,2,3 rs.addnew rs.fields("TodaysDate") = Now rs.fields("Email") = aspEmail rs.fields("Amount") = p rs.fields("Interest") = aspInterest rs.fields("Years") = y rs.fields("Monthly") = aspResult rs.fields("VAT") = aspVAT rs.fields("Total") = aspTotalVAT rs.update 'Check the AutoNumber field 'response.write rs("ID").Value aspID = rs("ID").Value rs.close cn.close set rs = nothing set cn = nothing ' Error Handling If Err.number <> 0 Then aspResult = "Could not calculate" aspVAT = "Could not calculate" aspTotalVAT = "Could not calculate" End If On Error Goto 0 End If %> <% If Request.Form("cmdSubmit") <> "" Then %> <% else %> <% end if %> <% If Request.Form("cmdSubmit") <> "" Then %> <% else %> <% end if %>
LEASE CALCULATOR
Your E-mail Address:
Loan Amount:
Term Over Number of Years:
<% if aspResult = "" then Response.Write "" else Response.Write "Monthly Payment:" end if %> <% if aspVAT = "" then Response.Write "" else Response.Write "£" Response.Write aspResult Response.Write" + VAT £" Response.Write aspVAT end if %>
<% if aspTotalVAT = "" then Response.Write "" else Response.Write "Total Monthly Payment:" end if %> <% if aspTotalVAT = "" then Response.Write "" else Response.Write "£" Response.Write aspTotalVAT end if %>

The Lease Calculator is for indication purposes only and subject to credit approval.

Rentals would be made monthly in advance.

An administration fee of 1% 0f the Capital cost net of VAT would be payable on signing, subject to a minimum of £100 + VAT.