Examining the VB Code for the VAT Calculator


Const VAT = 0.175
- tells VB that VAT will be a
constant value - this means that it won't change -  and sets it to 0.175 
(another way of writing 17.5%)

The next 3 lines tell VB we will use 3 other quantities in our calculation
Price, Tax and Total.
Each quantitiy that we use in a VB program is called a variable. We need to declare (or name) each variable that we use - and we also need to say what type of variable it is. Don't worry too much about how we do this at this stage!

The Price = Input Box ("Enter price of item")
- makes a
message box pop up, asking the user to
"Enter price of item" and confirm by pressing OK
It then sets this value as the
Price

Tax = Price * VAT
- stores the result of
Price x VAT in Tax
we use * to mean multiply in VB so that we don't get confused between multiplying and the letter x!

Total = Price + Tax
- stores the result of
Price + Tax in a variable called Cost

Form1.show - displays a form to the user

Form1.Print - prints out the message "The total price is " followed by the price with VAT
e.g.   The total cost is: 117.5


Back to Main Page
Hosted by www.Geocities.ws

1