back


A Program to Calculate Simple Interest
  1. Create a new Visual Basic Project
  2. Create three labels with the following captions:
    • Amount to invest
    • Interest rate
    • Time
  3. Use the default names for the labels
  4. Create three text boxes to go with the labels.
  5. Erase the text for each and change their names to the following:
    • txtAmount
    • txtInterest
    • txtYears
  6. Add one more label with no caption. Change its name property to lblTotal
  7. Add a command button. Change its caption to: calculate
  8. Add another command button. Change its caption to: clear
  9. 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)
  10. Double-click the clear button and add the following:
    txtAmount = ""
    txtInterest = ""
    txtYears = ""
    lblTotal = ""
  11. Run your program!