<%@ Language=VBSCRIPT %>
<%
dim sAction
sAction = CStr(request.querystring("action"))
Dim currentSession
currentSession = request.querystring("SessionID")
if currentSession = "" then
currentSession = request.form("SessionID")
end if
Dim DB_CONNECTIONSTRING
DB_CONNECTIONSTRING = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=p41mysql29.secureserver.net; PORT=3306; DATABASE=bzfinancial; USER=bzfinancial; PASSWORD='wsop2007Winner'; OPTION=0;"
dim objConnection
dim objRecordset
set objConnection = Server.CreateObject("ADODB.Connection")
set objRecordset = Server.CreateObject("ADODB.Recordset")
dim showDebtForm
showDebtForm = true
'if showDebtForm = true then
if currentSession = "" then
objRecordset.open "bzfinancial.Sessions",DB_CONNECTIONSTRING,0,2
objRecordset.addnew
objRecordset.fields("Session") = Now()
objRecordset.update
currentSession = objRecordset.Fields("SessionID").Value
objRecordset.close
objRecordset.open "SELECT * FROM bzfinancial.Sessions ORDER BY SessionID DESC;",DB_CONNECTIONSTRING,0,2
'objRecordset.movelast
currentSession = objRecordset.Fields("SessionID").Value
objRecordset.close
%>
Debt Freedom Calculator
Enter your debts in by filling in the appropriate fields and
clicking "Add".
When you are finished, click "Calculate".
The result you will see is what we consider the
"Worst-Case-Scenario" of your exact debt freedom date. All you have
to do is apply the principles that our consultants teach in the
financial consultation.
<%
else
dim addDebtName, addInterestRate, addBalance, addPayment
addDebtName = request.form("DebtName")
addInterestRate = request.form("InterestRate")
addBalance = request.form("Balance")
addPayment = request.form("Payment")
if addDebtName <> "" then
if addInterestRate <> "" then
addInterestRate = replace(addInterestRate,"%","")
if addBalance <> "" then
if addBalance <> "" then
objRecordset.open "bzfinancial.DebtCalculator",DB_CONNECTIONSTRING,0,2
objrecordset.addnew
objrecordset.fields("DebtName") = addDebtName
objRecordset.fields("DebtInterest") = addInterestRate
objRecordset.fields("DebtBalance") = addBalance
objRecordset.fields("DebtPayment") = addPayment
objRecordset.fields("AccellerateOrder") = addBalance / addPayment
objRecordset.fields("SessionID") = currentSession
objRecordset.update
objRecordset.close
end if
end if
end if
end if
objRecordset.open "SELECT * FROM bzfinancial.DebtCalculator WHERE SessionID=" & currentSession & ";",DB_CONNECTIONSTRING,0,2
dim showDebtTable
if objRecordset.RecordCount > 0 then
showDebtTable = true
else
showDebtTable = false
end if
dim debtID
dim debtName
dim debtInterest
dim debtBalance
dim debtPayment
dim accellerateOrder
%>
Debt Freedom Calculator
Enter your debts in by filling in the appropriate fields and
clicking "Add".
When you are finished, click "Calculate".
The result you will see is what we consider the
"Worst-Case-Scenario" of your exact debt freedom date. All you have
to do is apply the principles that our consultants teach in the
financial consultation.
<%
end if
set objRecordset = nothing
'end if
%>
<%
function NPer(Interest,Payment,Balance)
dim iNPer
dim thisMonthInterest
dim beginningBalance
dim endingBalance
beginningBalance = Balance
endingBalance = Balance
thisMonthInterest = beginningBalance*Interest
iNPer =1
do until beginningBalance <= 0
thisMonthInterest = beginningBalance*Interest
beginningBalance = CCur(beginningBalance) + CCur(thisMonthInterest)
endingBalance = beginningBalance + Payment
beginningBalance = endingBalance
iNPer = iNper +1
loop
Nper = iNPer
end function
function IPmt(Interest,Period,Term,Balance,payment)
dim dIPmt
dim thisMonthInterest
dim beginningBalance
dim endingBalance
beginningBalance = Balance
endingBalance = Balance
dIPmt = 0
dim I
for I = 1 to period
thismonthInterest = beginningBalance * Interest
beginningBalance = beginningBalance + thisMonthInterest
endingBalance = beginningBalance +payment
beginningBalance = endingBalance
next
IPmt = thisMonthInterest
end function
select case sAction
case "calculate"
response.write "
Your Debt Freedom Results
"
'dim objRecordset
set objRecordset = Server.CreateObject("ADODB.Recordset")
dim myValue
Randomize
myValue = Int((10*Rnd)+1)
dim oldTerm
dim mostMonths
dim period
dim oldInterest
dim totalOldInterest
dim balanceNow
dim principalCarryover
dim interestFactor
dim previousDebtMonths
dim totalNewInterest
dim accellerator
'dim debtBalance
'dim debtInterest
'dim debtPayment
dim paymentInterest
accellerator = 300
previousDebtMonths = 0
principalCarryover = 0
showDebtForm = false
objRecordset.open "SELECT * FROM bzfinancial.DebtCalculator WHERE SessionID=" & currentSession & " ORDER BY AccellerateOrder;",DB_CONNECTIONSTRING
objRecordset.movefirst
do until objRecordset.EOF
debtBalance = objRecordset.fields("DebtBalance")
debtInterest = objRecordset.fields("DebtInterest")
debtPayment = objRecordset.fields("DebtPayment")
paymentInterest = debtBalance * (debtInterest/100)/12
do until paymentInterest < debtPayment
debtPayment = debtPayment + 1
loop
oldterm = NPer((debtInterest/100)/12,-debtPayment,debtBalance)
if oldTerm > mostMonths then
mostMonths = oldTerm
end if
for period = 1 to oldTerm
oldInterest = IPmt((debtInterest/100)/12,period,oldTerm,debtBalance,-debtPayment)
totalOldInterest = totalOldInterest + oldInterest
next
balanceNow = objRecordset.fields("DebtBalance") + principalCarryover
interestFactor = (objRecordset.fields("DebtInterest")/100)/12
if previousDebtMonths >0 then
for period = 0 to previousDebtMonths - 1
totalNewInterest = totalNewInterest + (balanceNow * interestFactor)
balanceNow = (balanceNow+(balanceNow*interestFactor))-debtPayment
next
end if
Do Until balanceNow <= 0
totalNewInterest = totalNewInterest + (balanceNow * interestFactor)
balanceNow = (balanceNow + (balanceNow * interestFactor)) - (debtPayment + accellerator)
previousDebtMonths = previousDebtMonths + 1
newMonths = newMonths + 1
Loop
accellerator = accellerator + debtPayment
principalCarryover = balanceNow
objRecordset.movenext
loop
Dim i
Dim j
j=1
For i = 1 To mostMonths
If j = 12 Then
originalYears = originalYears + 1
j = 0
End If
j = J + 1
Next
originalMonths = mostMonths - (originalYears * 12)
i=0
j=1
for i = 1 to newMonths
if j = 12 then
newYears = newYears +1
j=0
end if
j=j+1
next
leftoverNewMonths = newmonths - (newyears*12)
response.write vbcrlf & vbcrlf & "
At the present rate, you will be debt free in " & originalYears & " years and " & originalMonths & " months" & vbCrLf & _
"And you will pay " & FormatCurrency(totalOldInterest) & " in interest over the term
" & _
"
If you do what our consultants teach, you will be debt free in " & newYears & " years and " & leftoverNewMonths & " months." & vbCrLf & _
"And you will save " & FormatCurrency(totalOldInterest-totalNewInterest) & " in interest.
"
response.write "
Ready to get started?
" & _
"
"
objRecordset.close
end select
%>