David Mason

06-21-2003, 07:06 AM

I call it pmtonapr and suggest you do the same.

function pmtonapr as N(mprinciple as N,mrate as N,mterm as N,mtermtype as n)

'1 = weekly - 2 = biweekly - 3 = monthly

'function pmtonapr as N(mprinciple as N,mrate as N,mterm as N,mtermtype as C)

dim years as n

dim peryear as n

dim t as n

dim n as n

dim N as n

dim r as n

dim R as n

dim P as n

if mtermtype=3 then

years = mterm/12

peryear = 12

elseif mtermtype=1 then

years = mterm/52

peryear = 52

elseif mtermtype=2 then

years = mterm/26

peryear = 26

elseif mtermtype= 4 then

years = mterm/24

peryear = 24

elseif mtermtype = 5 then

years = mterm/4

peryear = 4

elseif mtermtype = 6 then

years = mterm/2

peryear = 2

elseif mtermtype = 7 then

years = mterm

peryear = 1

end if

t = years

n = peryear

N = n*t

r = mrate/100

R = r/n

P = mprinciple

dim a as n

dim b as n

R=(mrate/100)/peryear

a=P*R*((1+R)^N)

b=(1+R)^N-1

pmtonapr = a/b

end function

function pmtonapr as N(mprinciple as N,mrate as N,mterm as N,mtermtype as n)

'1 = weekly - 2 = biweekly - 3 = monthly

'function pmtonapr as N(mprinciple as N,mrate as N,mterm as N,mtermtype as C)

dim years as n

dim peryear as n

dim t as n

dim n as n

dim N as n

dim r as n

dim R as n

dim P as n

if mtermtype=3 then

years = mterm/12

peryear = 12

elseif mtermtype=1 then

years = mterm/52

peryear = 52

elseif mtermtype=2 then

years = mterm/26

peryear = 26

elseif mtermtype= 4 then

years = mterm/24

peryear = 24

elseif mtermtype = 5 then

years = mterm/4

peryear = 4

elseif mtermtype = 6 then

years = mterm/2

peryear = 2

elseif mtermtype = 7 then

years = mterm

peryear = 1

end if

t = years

n = peryear

N = n*t

r = mrate/100

R = r/n

P = mprinciple

dim a as n

dim b as n

R=(mrate/100)/peryear

a=P*R*((1+R)^N)

b=(1+R)^N-1

pmtonapr = a/b

end function