Objectives:

  • Create Program That Calculates Simple Interest

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. Click on the text property for each text box and erase the text that is currently there. Make each one blank.

  6. Now, click on the name property. Change the name property of each text box to the following:

    txtAmount
    txtInterest
    txtYears

  7. Add one more label with no caption. Change its name property to lblTotal.

  8. Add a command button. Change its caption to: calculate.

  9. Add another command button. Change its caption to: clear.

  10. 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)

  11. Double-click the clear button and add the following:

    txtAmount = ""
    txtInterest = ""
    txtYears = ""
    lblTotal = ""

  12. Run your program!


<< Back to Skyline