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:
Public Class Form1
Private Sub cmdCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCompute.Click
Dim amount As Double
Dim begindate As Integer
Dim enddate As Integer
amount = CDbl(TxtInitialAmount.Text)
begindate = DateTimePickerFormat.Short
enddate = DateTimePickerFormat.Short
Label4.Text = ("You now have " & CDbl(amount * 1.01) & "")
End Sub
End Class
This works fine for 1 month, but I need to be able to determine the number of months between the begindate and the enddate, and then somehow use that figure 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 1368
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:
Public Class Form1
Private Sub cmdCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCompute.Click
Dim amount As Double
Dim begindate As Integer
Dim enddate As Integer
amount = CDbl(TxtInitialAmount.Text)
begindate = DateTimePickerFormat.Short
enddate = DateTimePickerFormat.Short
Label4.Text = ("You now have " & CDbl(amount * 1.01) & "")
End Sub
End Class
This works fine for 1 month, but I need to be able to determine the number of months between the begindate and the enddate, and then somehow use that figure 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.
Hi.
I think I have a grasp of what you want to do. If we just stick with the date part.
You might look up the DateDiff() function.
In terms of your request it might look like this
Dim lngMonths As Long
lngMonths = DateDiff("m", begindate, enddate)
Hope this is useful
Thank you so much for your guidance! Works fine now and I have learned something new!!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: kie |
last post by:
hello,
i have a table that creates and deletes rows dynamically using
createElement, appendChild, removeChild.
when i have added the required amount of rows and input my data, i
would like to...
|
by: Jason |
last post by:
I need help designing a query (or two) in MS Access that will
calculate a compounded rate of interest. This would be no problem
using a simple FV function if the Interest Rate were constant....
|
by: Veger |
last post by:
I'm having some logic trouble (IE: I can't figure out how to do this)
I have an assignment in which I need to calculate annual interest.
IE:
P1 = P0 + P0*INT (interest) = P0*(1+INT)
P2 = P1 +...
|
by: Yotam |
last post by:
Hi,
I need some help with JS. I will be grateful, if you can help me out.
I have two date fields (check in, check out) and "number of days"
field.
I want the script to calculate automatically...
|
by: debi.robarts |
last post by:
I am setting up a database to keep track of network leases.
I have a field for "original rent" and then fields to capture how it
escalates (what % how often).
I want to set up fields that give 1)...
|
by: dos.fishing |
last post by:
Hello,
I'm writing a function that should do the following:
/**
* Calculate and return fraction of valueA where max fractions is 31.
* param valueA A five bit value, 0-31.
* param valueB The...
|
by: fatimahtaher |
last post by:
Hi,
I am new to C# programming and my first assignment requires me to calculate total interest paid on a loan. The user will input the loan, the interest rate per month, and the monthly payment....
|
by: Joseph Geretz |
last post by:
I need to calculate miles per degree longitude, which obviously depends on
latitude since lines of longitude converge at the poles. Via Google, I've
come up with the following calculation:
...
|
by: =?Utf-8?B?TmF2YW5lZXRoLksuTg==?= |
last post by:
Say I have a class like,
class Sample
{
public decimal first = 10;
public decimal second = 20;
}
I have initialized it
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |