Compounding Interest
Using the foruma found at: http://www.vbforums.com/showthread.p...nding+interest
I need to solve for t (years) for: A = P (1 + r) ^ t
I am going to be given A, P, and R. I need this for a VB6 program.
Any help would be appreciated. Thanks!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Compounding Interest Problem
Working on a Wealth Accumulator program, in which the user inputs an amount for a monthly deposit, determines the number of times in a row it will be done, and the annual interest rate it will earn.
I have everything working except for the Interest Earned statement, if someone could look over my code, or the form attached to give me some pointer i would appreciate it as i'm spinning my wheels. I can't figure out the proper equation or something..
Code:
Option Explicit
Dim dblBalance As Currency
Dim sngMonthlyReturn As Currency 'the Monthly Return including Interest
Dim dblMonthlyInterest As Double 'dollars of interest earned this month
Dim dblTotalDeposited As Double 'Total Deposited accumlator
Dim dblTotalInterest As Double 'interst earned accumlator
Dim dblAccountBalance As Double 'Account Balance accumlator
Dim intCounter As Integer
Private Sub cmd_calculate_Click()
Dim sngMonthlyRate As Currency 'the monthly interest rate
sngMonthlyRate = (txt_annual_interest_rate) / 12 'determines the monthly interest rate
dblMonthlyInterest = 0
dblTotalDeposited = 0
dblTotalInterest = 0
dblAccountBalance = 0
For intCounter = 1 To txt_number_deposits.Text
dblTotalDeposited = dblTotalDeposited + txt_monthly_deposits
dblMonthlyInterest = (dblTotalDeposited * sngMonthlyRate) 'determines how much interest is earned each month
sngMonthlyReturn = txt_monthly_deposits + (dblMonthlyInterest) 'determines the return for a month
dblTotalInterest = dblMonthlyInterest * (txt_number_deposits)
dblBalance = (dblBalance) + (txt_monthly_deposits.Text * sngMonthlyRate)
dblTotalInterest = (dblTotalDeposited) * (sngMonthlyRate) * (txt_number_deposits.Text)
MsgBox (dblTotalInterest)
Next intCounter
dblAccountBalance = (dblTotalDeposited) + (dblTotalInterest)
txt_total_deposited.Text = FormatCurrency(dblTotalDeposited)
txt_interest_earned.Text = FormatCurrency(dblTotalInterest)
txt_final_balance.Text = FormatCurrency(dblAccountBalance)
End Sub
Conditional Compounding Function (similar To FVSCHEDULE)
Can anybody offer any advice on how to create a function to geometrically link together a series of compound interest rates (similar to the FVSCHEDULE function in Excel), but with conditions applied. An example of my problem is as follows:
I have 4 columns of data, column A containing names of different banks, column B containing the account type, column C containing the months of the year, and column D containing compound interest rates relating to the bank, account type and month in the same row. Underneath the rows of data, I am looking to insert a function that will take only interest rates for, say, "Bank of America" for their "Current" Account type, and compond the interest rates to get a total. The formula for this would be (1+a)*(1+b)*.....*(1+n)1 for interest rates a, b, ..., n.
I know that the FVSCHEDULE function can provide me with a solution if I wanted to compound ALL of the interest rates together, ie. with no conditions applied, so I thought I would modify this function and create an array under the columns of data, so applied to the example above would the array would be:
{=FVSCHEDULE(1,IF((A1:A100="Bank of America)*(B1:B100="Current"),D1100))1}
However, this array results in #VALUE!. If I use a similar array but containing the SUM function instead of FVSCHEDULE, then this applies the conditions and works OK, so I think I must be either misusing the FVSCHEDULE function or it simply does not work in Excel.
I then went on to write a custom function in VBA to compound rates together, as follows:
'*************************************
Function COMPOUND(Returns As Object)
On Error GoTo ErrorHandler
For Each cell In Returns
If IsNumeric(cell.Value) = False Then
GoTo ErrorHandler
Exit For
End If
Next cell
n = Returns.Count
COMPOUND = 1
For x = 1 To n
COMPOUND = COMPOUND * (1 + Returns(x) / 100)
Next x
COMPOUND = COMPOUND  1
COMPOUND = COMPOUND * 100
Exit Function
ErrorHandler:
COMPOUND = "Error"
End Function
'*************************************
I then applied this function to the array instead of the FVSCHEDULE function:
{=COMPOUND(IF((A1:A100="Bank of America)*(B1:B100="Current"),D1100))}
This also returns #VALUE!, which may be because the function I wrote requires all data values to be next to each other, but I'm not sure. So I've hit a bit of a dead end with this. Any suggestions, either on why it is not working, or for a possible solution would be more than welcome!
Thanks
Out Of Interest
Just out of interest.
Is there any differance between these statements?
if x = Chr(69) thenORif x = "E" then
Is one quicker or more correct than the other?
Interest Calculator
I need help, I am not sure where to plugin the values that my teacher gave me for this problem. Here is the code that I have so far.
Code:
Option Explicit
Dim A As Double
Dim B As Double
Dim C As Double
Dim D As Double
Private Sub cmdcalc_Click()
A = Val(txtdep.Text)
B = Val(txtint.Text / 1200)
C = Val(txtmon.Text)
D = Val(txtbal.Text)
D = C * ((1 + B) ^ C  1) / B
txtbal.Value = Format(D, "#######.00")
End Sub
Private Sub cmdclr_Click()
A = Empty
B = Empty
C = Empty
D = Empty
txtdep = ""
txtint = ""
txtmon = ""
txtbal = ""
End Sub
Private Sub cmdexit_Click()
End
End Sub
Private Sub UserForm_Click()
End Sub
The values that he wants up to plugin are as follows.
note, you put in interest rate and the program divides by 1200, like below
intrate= interest (then number)/1200
say interest= 10
intrate= 10/1200
months = Log(finalvalue * intrate / deposit + 1) / Log(1 + intrate)
deposit = final / (((1 + intrate) ^ months  1) / intrate)
final = deposit * ((1 + intrate) ^ months  1) / intrate
as of right now, it doesn't matter what I put in for deposit, It only calculates the interest rate and the months. Any help would be appreciated.
Bank Interest
i need to create a program that will allow a user to enter amount after 5,10,15,20,25,30 years have it be compounded with 10% interest every 365 days help plz
Calculating Interest
I am working on a program in which the user enters an amount of money in a textbox, selects a beginning and ending date using the datetimepicker, and then the program calculates the new amount based on an interest rate of 1% compounded monthly. The code I have written is as follows:
VB Code:
Public Class Form1 Private Sub cmdCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCompute.Click Dim startdate Dim enddate Dim lngMonths As Long Dim amount As Double amount = txtInitialAmount.Text startdate = DateStart.Value.ToShortDateString enddate = DateEnd.Value.ToShortDateString lngMonths = DateDiff("m", startdate, enddate) lblResult.Text = amount * 1.01 * lngMonths End SubEnd Class
Tthe number of months between the startdate and the enddate is given in lngMonths, but I need to somehow use that figure from lngMonths in the formula so that if, for example, the user selects 3 months the formula will be amount * 1.01*1.01*1.01.
I know what I need to do, but don't seem to be able to get there!! Any guidance would be appreciated.
Calculate Interest?
Greetings all,
I'm trying to get this to work properly, its to calculate profit and new account balance as u put the money in a bank for interest.
For example, if we have a balance of $1000 in our account and we wish to know how much we will have in the account after 3 months using an annual interest rate of 4.5% compounded monthly:
After first month: interest earned = $1000 * 4.5 / 100 / 12 = $3.75
new balance = $1000 + $3.75 = $1003.75
After second month: interest earned = $1003.75 * 4.5 / 100 / 12 = $3.76
new balance = $1003.75 + $3.76 = $1007.51
After third month: interest earned = $1007.51 * 4.5 / 100 / 12 = $3.78
new balance = $1007.51 + $3.78 = $1011.29
So, after 3 months we will have $1011.29 in our account and we will have earned $11.29.
My code is:
VB Code:
Private Sub cmdCalculate_Click() 'Proform calculations txtProfit.Text = Val(txtAccountbalance.Text) * 4.5 / 100 / Val(txtDuration.Text) txtNewbalance.Text = Val(txtProfit.Text) + Val(txtAccountbalance.Text) 'To correct values to 2 decimal places since it is money. txtNewbalance.Text = Format(txtNewbalance.Text, "currency") txtProfit.Text = Format(txtProfit.Text, "currency") End Sub
it doesnt work really well.. could someone tell me wad code to write?
My screenshot is attached below:
Calculate Interest
i have some problems with this calculate interest. For example:if we have a balance of $1000 in our account and we wish to know how much we will have in the account after 3 months using an annual interest rate of 4.5% compounded monthly:
After first month: interest earned = $1000 * 4.5 / 100 / 12 = $3.75
new balance = $1000 + $3.75 = $1003.75
After second month: interest earned = $1003.75 * 4.5 / 100 / 12 = $3.76
new balance = $1003.75 + $3.76 = $1007.51
After third month: interest earned = $1007.51 * 4.5 / 100 / 12 = $3.78
new balance = $1007.51 + $3.78 = $1011.29
So, after 3 months we will have $1011.29 in our account and we will have earned $11.29.
Can you help me,plz.Thanks a lot
Calculating Interest
i have some problems with calculating interest. For example:if we have a balance of $1000 in our account and we wish to know how much we will have in the account after 3 months using an annual interest rate of 4.5% compounded monthly:
After first month: interest earned = $1000 * 4.5 / 100 / 12 = $3.75
new balance = $1000 + $3.75 = $1003.75
After second month: interest earned = $1003.75 * 4.5 / 100 / 12 = $3.76
new balance = $1003.75 + $3.76 = $1007.51
After third month: interest earned = $1007.51 * 4.5 / 100 / 12 = $3.78
new balance = $1007.51 + $3.78 = $1011.29
So, after 3 months we will have $1011.29 in our account and we will have earned $11.29.
Anyone can help me?Thanks a lot
Interest Calculator Help
I'm making an Interest Calculator for a comp prog class and I have everything done except a monthly Interest Rate. I need to display how much you would pay a month for x amount of years and x interest for x amount of dollars. My problem is my variable for monthly interest rate has a value of zero, which messes up all my monthly total payment.
Here is my code...
Private Sub chkMonthly_Click()
'Sends Monthly Payments to lstMonthlyPayments
intCounter = 1
curPrincipal = Val(txtAmount)
lstMonthlyDisplay.AddItem ("Month" & vbTab & "Amount Payed")
dblMthInterestRate = Val(txtInterest / (12 * 100))
intMonths = (intYears * 12)
curMonthlyPayment = curPrincipal * (dblMthInterestRate / (1  (1 + dblMthInterestRate) ^ intMonths))
txtMonthlyPayment = Format(curMonthlyPayment, "$######.00")
txtTotalInterest = (dblMthInterestRate * intMonths)
dblMthInterestRate = Format(dblMthInterestRate, "$######.00")
For intCounter = 1 To (intYears * 12)
curTotalPayment = (curTotalPayment + curMonthlyPayment)
curTotalPayment = curTotalPayment + dblMthInterestRate
lstMonthlyDisplay.AddItem (intCounter & vbTab & Format(curTotalPayment, "$######.00"))
Next intCounter
The variable in red is the variable that has no value.
CAN ANYONE HELP.
Out Of Interest Question
If I would like to havein an app a Window (RTF or TXT or ...) which shows the
code of the app (ASM or even BIN) how would I do this
What I wand to say
If you do somthing in your app the code for this (BIN) is shown
Out Of Interest Question
Greetings, what do you think is the advantage / disadvantage for the following senarios?
Ex1. Having a variable global for the whole app
Ex2. Having a variable in a class for the whole app
Ex3. Having a variable in a ATL for the whole app
Ex4. Having a variable in a DLL for the whole app
As A Matter Of Interest...
I've read it somewhere (probably on this site!) how you can disble Ctrl+Alt+Del and stuff like that, and I even know how it works (you trick the computer into thinking a screensaver is running), but I can't for the life of me remember the code. Does anybody know?
Read This, Might Be Of Interest To You
Hello everyone...
I used to be a lone coder... but now I'm trying to get a group of coders/artists together, and make a small company (I don't like to call it that). I would like to know who's interested in joining me, the whole purpose of this is to learn, yes, learn, to learn from each other, and to learn how to work together in a team enviornment... We will be completely NonCommercial.. whatever we make will be available for free, and sometimes even with source code, if you want to join, just reply here, and/or send me an email at "falcon@punkass.com" (I preffer if you reply right here..) we will usually be working on graphical programs, like games, and/or internet projects or other typical aplications that won't look like your typical windows application but rather very graphical... we will also be learning in this process, learning to code in DirectX and so forth.. I've signed up for the website at "http://MFProductions.tripod.com/" the group will be called MFProductions (MF = Don't ask me yet).... So if you guys are interested and have a lot of free time in hand and stuff like that, then join up, I'll only be taking like 6 people that are coders, and if you have any specialty like graphics and stuff, I'll pick you in the other category.. don't be offended if I don't pick you... ok???
Thanks a lot
Compound Interest
i am working on a simple bank project in which we r having module in which we have to calcaulate the compound interest. the problem is like this
no. of. months, rate of interest and totals amounts are the inputs. the interest should be calculated for every quarter and the resultant should be added to balance and for the next quarter the interest should be calculated on the entire balance amount. and it should also calculate the interst for the days also and the interest should be cumulated to nearest quarter balnace.
pleae provide me the logical solution. for this.
Interest Rates Calculations?
Is their a excel function for calculating interest rate repayments?
Basicly what I have to do is set up an Excel sheet that allows amount, a period and an interest rate and the sheet calculates the repayments over the period?
I just thought that their maybe a excel functions that would do this for me??
Total Interest Paid
Can someone tell me how to calculate the total interest paid on a loan?
I have the payment calculated, I just need the total interest at the end of the loan.
Thanks
Dale
Select Area Of Interest
I need to select an area of a picture I want to zoom into.I want to use the mouse to drag and select the area.How can this be done?currently the picture is loaded into a picture box and i am able to zoom into a fixed area of the picture....thanks for any help
Calculate Simple Interest
I have a label and a single textbox and 2 command buttons ie Calculate & exit now i want to calculate simple interest ie Simple Interest=(principal*Time*Rate)/100 can u tell me how can i enter values and show the result only byt clicking 4 times in the one of the command button(ie calculate)
if possible please mail me at uddipto_banerji@indiatimes.com
Simple Interest Program Help!!
I am new to visual basic and I am trying to write a program that uses the formula interest = principal x rate x days / 365. I would input the rate and days for several loans and using the formula it would calculate and display the interest for each loan. I have worked on this and worked on this and still I cannot get it to work. It was a class assignment that I was not able to complete. I've finished the class but it still has me stumped. I took an internet based class for this. Book was not very good and needed more access to the teacher. Any suggestions, advice, etc???
Any Interest? Serverless Web Development
I've duplicated myself!
The original of this was moved to the Code Bank:
http://www.vbcity.com/forums/topic.asp?tid=93772
Edited by  dilettante on 7/3/2005 1:28:13 PM
Interest And Mortgage Calculating
Does anyone know where I might find VB code for calculating income interest (compounding method, simple, monthly, quarterly, etc.). Also would like to find code for calculating mortgage payments (maybe form that ask for loan amount, down payment, term, etc.)
Help: Dynamic Accrued Interest Calculator
I'm a hack begging for some help here.
Currently, we waste a lot of time calculating accrued interest and total months paid on clients revolving accounts (Credit Cards) using a java script (included Below) found on the web. Then imputing the results by hand. Slow and error prone.
Script follows:
Code:
//By Daniel C. Peterson
//Web Winder Website Services, 19972005 All Rights Reserved.
//Distribution, editing or reselling of this script is strictyly prohibited
//without expressed written permission from Daniel C. Peterson.
//For commercial grade (professional) versions of this and many other
//calculators, visit [url]http://www.webwinder.com[/url].
function computeForm(form) {
var i = form.interest.value;
if (i > 1.0) {
i = i / 100.0;
form.interest.value = i;
}
i /= 12;
var j = form.minpayperc.value;
if (j > 1.0) {
j = j / 100.0;
j = j * 1;
}
var prin = eval(form.principal.value);
var pmt = 0;
var prinPort = 0;
var intPort = 0;
var count = 0;
accruedInt = 0;
while(prin > 0) {
if(eval(prin * j) < eval(form.minpaydol.value)) {pmt = eval(form.minpaydol.value); } else { pmt = eval(j * prin); }
intPort = eval(i * prin);
prinPort = eval(pmt  intPort);
prin = eval(prin  prinPort);
accruedInt = eval(accruedInt + intPort);
count = count + 1
if(count > 600) { break; } else { continue;}
}
<more script of little importance>
The reason I have not used Excel's built in functions? Not dynamic (can't use minimum payment or minimum percent paid). Of course if any know how this can be accomplished using builtin functions that would be great.
I'd like to write a series of functions that will dynamically calculate Accrued InterestCCA (credit card accrued int) and Total MonthsCCPer (credit card periods) as the above script does sourcing Balance (Principle), Interest Rate, MinPay (Dollars) and MinPay (Percent) from cells in the work sheet. Thus far (only a few hours work, I'm trying to learn VB simultaneously, so mercifully examine my attempt) my function script returns errors or zeros at best.
Submitted below are the two functions:
Code:
Public Function CCA(Bal As Currency, Rate As Integer, MinPay As Currency, _
MinPerc As Integer) As Currency
'Attribute CCA.VB_Description = "Calculates the accrued interest of revolving _
credit."
'Define variables
Dim Prin As Double
Dim IntP As Double
Dim PrinP As Double
Dim Pmt As Double
Dim AccInt As Double
Dim Count As Double
'Prepare Rates for calculation
If Rate > 1 Then Rate = Rate / 100
If MinPerc > 1 Then MinPerc = MinPerc / 100
'Source variables
Prin = Bal
'Loop Pmt until Pmt = 0
Do While Prin > 0
If (Prin * MinPerc) < MinPay Then
Pmt = MinPay 'Establish Var Pmt
Else
Pmt = (Prin * MinPerc)
IntP = (Prin * Rate)
PrinP = (Pmt  IntP)
Prin = (Prin  PrinP)
AccInt = (AccInt + IntP)
Count = Count + 1
If Count > 600 Then Stop
End If
Loop
End Function
Public Function CCPer(Bal As Currency, Rate As Integer, MinPay As Currency, _
MinPerc As Integer) As Double
'Attribute CCPer.VB_Description = "CCPer calculates the months (periods) to pay_
off revolving credit making only the minimum payment."
'Define variables
Dim Prin As Double
Dim IntP As Double
Dim PrinP As Double
Dim Pmt As Double
Dim Count As Double
'Prepare Rates for calculation
If Rate > 1 Then Rate = Rate / 100
If MinPerc > 1 Then MinPerc = MinPerc / 100
'Source variables
Prin = Bal
'Loop Pmt until Pmt = 0
Do While Prin > 0
If (Prin * MinPerc) < MinPay Then
Pmt = MinPay 'Establish Var Pmt
Else
Pmt = (Prin * MinPerc)
IntP = (Prin * Rate)
PrinP = (Pmt  IntP)
Prin = (Prin  PrinP)
Count = Count + 1
If Count > 600 Then Stop
End If
End Function
Any entrepenuers out there know if you have any abilities they will be used *cough* abused when starting a company, such is my plight (I've never coded a line in my life before yesterday)
All help is greatly appreciated.
DBG
P.S. I've also attached the spreadsheet.zip
Compound Interest Calculation Problem
I am very new to Visual Basic, I need help getting the "Calculate Earnings" to be calculate correctly.
Also in the attached screenshots I need the calculation to appear in the 3 bottom text boxes.
I made a couple messages boxes that are doing fine and serving their purpose so they are doing okay.
Thanks for any help you can provide.
Michelle
VB: Compound Interest Extras Program
I'm doing a compound interest program... I have the main part of it done... enter in an amount and interest rate (annually)... I need it to spit out the amount of time in years it will take to double the money and the amount of time in years to reach a million dollars.... any ideas???
I have the picture boxes and everything laid out... amount and interest rate are labels... and then 2 seperate txt boxes... click button to determine years.... and then doubling time is a label and reach a million is a label.... both doubling time and reach a million are done in picture boxes
Thanks
Annual Interest Rate Project
This is one of our final projects of the year and its **** hard! Any help would be appriciated.

Your program will prompt the user for an expected annual interest rate, a range of years that will be illustrated, and the rage of dollar value that can be invested at a set rate per year. The program will generate a table similar to the one that follows in figuar 1. ( I cant really type up the whole table!!)
The table in Figuar 1 demonstrates that $100 invested every year for 5 years at 6% will generate $597.53, and $500 invested every year for 25 years at 6% will generate $29,078.19.
Visual Basic has a function that will do most of the work for you.
FV(interest rate per paypment, number of payments, dollar amount per payment)
note: the value generated by FV function does not include the interest for the last payment. You will need to consider the last interest payment in your calclation.

So far I have been able to get the first Horizontal and Vertical colombs which have the number of years and dollar value. 5 to 25 years. 100 to 500 dollars inc. 20.
i need to find out how to use the for next statment to get the rest.
Security Issue  Of Guru Interest
Let me give an example of my concerns.
Today I was requested by the support staff of a large corporation to allow them to link to my computer.
To the best of my knowledge, I do NOT have Remote or Terminal Services loaded. Looking both in the registery and under system information everything appears normal  no services running.
I NO longer had the companies Software loaded and had scanned the Registry and no entries appeared to be left over.
I did manually reregister their primary DLL (c:windowssystem)and included three other of their DLLs (c:windowssystem)  these are supporting DLLs used by the primary DLL.
I dialed up a web address on their server, responded  OK to access my system , and instantly, they had control of the client side cursor.
QUESTIONS
1) How are they able to establish handshaking with my system which allows them complete control  e.g. use of their DLL, Internet Explorer ???
2) Is there any way to limit their access to my HD once they're on my system?
3) Is there any way (program if you know of one) that will allow me to interactively monitor and log their activity while connected?
Thanks
David
Thanks
David
Interest Calculation Program [ Solved ]
Hello guys,
Can anyone please tell me how to calculate interest in a VB program, examples would do as well.
I actually need only the formula to calculate interest.
Thanx
Hannes
Need Help Figuring Recurring APR And Interest Rate
I have a database of customers which holds their personal and transactional data from the sale of books. Am including a sample of it.
What I have is a query that at the moment can't:
1. Figure the A.P.R. of 18% on the outstanding balance
(The interest calculated monthly and added to the balance before the monthly bill is issued).
Which I don't think would be to difficult as I've written this already into my query, but how do I make it see the next month, and the next month on any remaining balance if they have not paid in full yet?
2. All bills are issued on the last day of the month, and payment is due on the 15th of the following month.
(If payment is not received by the 15th, a late notice is mailed, and an additional 1% is added for overdue accounts...this is added to the balance as an additional interest.
Again, I can figure the interest cost, but how do I make it see the next month, and the next month on any remaining balance if they have not paid in full yet?
When I open the query, I would like it to adjust to see the new date, and adjust all figures (monthly A.P.R of 18% and interest accrued as late fee (1%)?
I am curious if I shouldn't be doing this with code. Any ideas, and suggestions on the way the database is setup to make this more accomodating to my goal, I'd sure appreciate the help.
Thank you
NMP
Frustrating  How To Do Coumpund Interest In VB? (harder Than It Sounds)
How would you do compound interest in VB, where the user inputs the time to pay the mortgage, the interest rate, and the cost of the mortgage now, and the program has to figure out the amount that needs to be paid per period.
at first i thought it would be simple but its not
I think the problem is why i dont know how to do it is that with a program like this, there can be many different values for the amount to pay per period to satisfy the criteria set by the user..
anyone know how to do this?
Formula For Interest Portion Of A Payment For A CANADIAN MORTGAGE (semiannually)
Hi,
I know about VB's functions to calculate mortgage payments. However they do not apply to Canadian mortgages which are compounded semiannually as opposed to monthly.
I can calculate mortgage payments.
However in order to create amortization table, I also need to calculate interest portion of a mortgage payment for a CANADIAN MORTGAGE (compounded semiannually).
What is the formula?
Thanks,
Tom
