Objectives:
- Create Program That Calculates Simple Interest
|
A Program to Calculate Simple Interest
- Create a new Visual Basic Project.
- Create three labels with the following captions:
Amount to invest
Interest rate
Time
- Use the default names for the labels.
- Create three text boxes to go with the labels.
- Click on the text property for each text box and erase the text that is currently there. Make each one blank.
- Now, click on the name property.
Change the name property of each text box to the following:
txtAmount
txtInterest
txtYears
- Add one more label with no caption. Change its name property to lblTotal.
- Add a command button. Change its caption to: calculate.
- Add another command button. Change its caption to: clear.
- Double-click the calculate button and add the following code:
Dim Amount, Interest, Time, Total
Amount = Val(txtAmount)
Interest = Val(txtInterest)
Time = Val(txtYears)
Total = Amount + Amount * (Interest * Time)
lblTotal = Val(Total)
- Double-click the clear button and add the following:
txtAmount = ""
txtInterest = ""
txtYears = ""
lblTotal = ""
- Run your program!
<< Back to Skyline
|