|
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.
- Erase the text for each and change their names 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 command 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!
|
|