Results 1 to 2 of 2

Thread: [RESOLVED] calculating interest

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    59

    Resolved [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:
    1. Public Class Form1
    2.  
    3.     Private Sub cmdCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCompute.Click
    4.         Dim startdate
    5.         Dim enddate
    6.         Dim lngMonths As Long
    7.         Dim amount As Double
    8.  
    9.  
    10.         amount = txtInitialAmount.Text
    11.  
    12.         startdate = DateStart.Value.ToShortDateString
    13.         enddate = DateEnd.Value.ToShortDateString
    14.         lngMonths = DateDiff("m", startdate, enddate)
    15.  
    16.  
    17.         lblResult.Text = amount * 1.01 * lngMonths
    18.  
    19.     End Sub
    20. 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.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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
  •  



Click Here to Expand Forum to Full Width