Guaranteed Hits to your web site!












Learn Visual Basic 6.0


2. The Visual Basic Language


Example 2-3: Savings Account - Decisions

  1. Here, we modify the Savings Account project to allow entering any three values and computing the fourth. First, add a third command button that will clear all of the text boxes. Assign the following properties:

    Command3: Caption Clear &Boxes
    Name cmdClear

    The form should look something like this when you�re done:


    Saving Account



  2. Code the cmdClear button Click event:
    This code simply blanks out the four text boxes when the Clear button is clicked.

  3. Code the KeyPress event for the txtFinal object:
    We need this code because we can now enter information into the Final Value text box.

  4. The modified code for the Click event of the cmdCalculate button is:
    In this code. we first read the text information from all four text boxes and based on which one is blank, compute the missing information and display it in the corresponding text box. Solving for missing Deposit, Months, or Final information is a straightforward manipulation of the equation given in Example 2-2.

    If the Interest value is missing, we have to solve an Mth-order polynomial using something called Newton-Raphson iteration - a good example of using a Do loop. Finding the Interest value is straightforward. What we do is guess at what the interest is, compute a better guess (using Newton-Raphson iteration), and repeat the process (loop) until the old guess and the new guess are close to each other. You can see each step in the code.

  5. Test and save your application. Go home and relax.


Pen Line


Counter Hit Counter Hit


This Homepage is special brought to you by CK Tan
Hosted by www.Geocities.ws

1