MS-Excel PMT function emulation

Results 1 to 2 of 2

Thread: MS-Excel PMT function emulation

  1. #1
    Join Date
    Dec 1969

    Default MS-Excel PMT function emulation

    Hi,<BR>I have a job of creating a web version of a loan calculator which is currently built in Ms-Excel.In Excel they hv used PMT functionfor some calculations. Is there any Equivalent function in Vbscript? If not then what is the formula behind this function,so that I hv to build it on my own. U see i&#039;m not much of finance guy. so...<BR>Thanks guys.<BR>Abhra

  2. #2
    Join Date
    Dec 1969

    Default RE: MS-Excel PMT function emulation

    I encountered the same issue with my code at one point, here is the code you are looking for in JavaScript, you will likely need to modify the names, but it takes a box for principal amount, rate and term and does the math from there. It has a select case statement in there in case the term chosen is a balloon note (30 due in 15). Let me know if it works out for you.<BR><BR>function calcPI() {<BR><BR> var principal = document.analysis.loan_amt.value;<BR> var interest = document.analysis.interest_rate.value;<BR> <BR> switch (window.document.analysis.term.value)<BR> {<BR> <BR> case "60":<BR> <BR> var term = 60<BR> <BR> break<BR> <BR> case "120":<BR> <BR> var term = 120<BR> <BR> break<BR> <BR> case "180":<BR> <BR> var term = 180<BR> <BR> break<BR> <BR> case "240":<BR> <BR> var term = 240<BR> <BR> break<BR> <BR> case "300":<BR> <BR> var term = 300<BR> <BR> break<BR> <BR> case "360":<BR> <BR> var term = 360<BR> <BR> break<BR> <BR> case "360/180":<BR> <BR> var term = 360<BR> <BR> break<BR> <BR> default:<BR> <BR> var term = 0 <BR> <BR> } <BR> <BR> var x = (principal) * ((interest/100)/12) * (Math.pow(1+((interest/100)/12),term));<BR> var y = (Math.pow(1 + ((interest/100)/12), term)-1)<BR> var z = x/y <BR> var num = z;<BR><BR><BR><BR> num = Math.floor(num*100+0.50000000001);<BR> <BR> cents = num%100;<BR><BR> num = Math.floor(num/100).toString();<BR><BR> if (cents &#060; 10)<BR><BR> cents = "0" + cents;<BR><BR> document.analysis.new_second_pi.value = (num + "." + cents);<BR><BR> document.analysis.new_second_pi_1.value = (num + "." + cents);<BR><BR> document.analysis.loan_amt_1.value = principal;<BR><BR> document.analysis.loan_amt_2.value = principal;<BR> }<BR><BR>

Posting Permissions

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