• home
  • forum
  • my
  • kt
  • download
  • Calculating the Area of a Rectangle using Visual Basic 6

    Author: 2007-09-05 18:11:15 From:

    Calculating the Area of a Rectangle in Visual Basic 6

    When doing Software Design at school, one of my assignments was to create an application that calculated the Area of a rectangle. When I did it, I struggled to find a site that actually helped me, so I¡¯ve made this tutorial for anyone else who may struggle.

    1. Open Visual Basic 6
    2. Create a New Form
    3. Create Three (3) Text boxes
    4. Select the first box and go to the Properties window
    5. Change the Name to txtLength
    6. Select the second box and change the name to txtWidth
    7. Select the third box and change the name to txtArea
    8. Create a Button
    9. Change the Name to cmdButton
    10. Under the Project menu, right click on Form1 and click View Code
    11. In the first drop-down box select cmdCalculate
    12. In the second drop-down box select Click
    13. You should now see:
    14. Type the following:

    What this code does:

      • Creates 3 variables: rec1, rec2, rec3
      • These variables have all be defined as Integers (whole numbers)
    1. Type the following:

    What this code does:

      • Makes rec1 equal to the value of the text box txtLength
      • Makes rec2 equal to the value of the text box txtWidth
      • Makes rec3 equal to the value of rec1 multiplied by rec2.
      • * is the symbol used for multiplication in Visual Basic (and many other programming languages)
    1. Now type:

      This code simply displays the result of the calculation made in the previous step.
    2. Press the Start button to test your program

    Final Result

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      .NET (8)
      Buttons (3)
      Database Related (7)
      Date and Time (1)
      Development (3)
      Error Handling (2)
      File Manipulation (5)
      Introduction to Visual Basic (9)
      Miscellaneous (2)
      Multimedia (9)
      Networking (9)
      Security (1)
      VB Script (6)

    New

    Hot