|
-
Jan 10th, 2007, 04:13 PM
#1
Thread Starter
Member
[RESOLVED] 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 Sub
End 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.
-
Jan 10th, 2007, 06:26 PM
#2
Re: [RESOLVED] calculating interest
Look at the code here. Leave out the Option Compare Database.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|