Presentation is loading. Please wait.

Presentation is loading. Please wait.

VAT Calculator program Controls Properties Code Results.

Similar presentations


Presentation on theme: "VAT Calculator program Controls Properties Code Results."— Presentation transcript:

1 VAT Calculator program Controls Properties Code Results

2 The control objects are selected and placed on the Form

3 The Controls on the form

4 The caption, background colours, font size & colours and other conditions are set in the properties windows for the object

5 Adding the Code The code window can be accessed by double clicking the object. It takes you to the exact place in the code listing the next sections show the code, the controls and the results in the running application Note the documentary comments in green

6 Private Sub Form_Load() 'this application is a simple design for a VAT calculator. 'version 1.1 'author T.Vincent WCT 'October 19 2002 lblmessage2.Caption = "Please press the start button" 'initial instructions End Sub

7 Private Sub cmdStart_Click() txtentdata.Text = "" 'reset the text box lblMessage.Caption = "" 'clear the label message lblmessage2.Caption = "Please type the cost of the product in the box below and then click the Enter button" 'instructions entered in label box txtentdata.SetFocus 'place cursor ready for entering cost of item End Sub

8 Private Sub cmdEnter_Click() lblMessage.Caption = "You have entered £" & txtentdata.Text 'verification of data entry lblmessage2.Caption = " If this is wrong please press the start button again" ' user validation End Sub

9 Private Sub cmdVatcalc_Click() Dim sngProdprice As Single 'define data types for data input as single Dim sngVatcost As Single 'define reult of calculation as single On Error GoTo ErrorHandler 'error trap to catch none numeric values Exit Sub ErrorHandler: 'error handling routine for none numeric data lblmessage2.Caption = " You must enter only a number. Please Press Start again" ' error message to return to start Exit Sub

10 sngProdprice = txtentdata.Text 'change text data from input to string sngVatcost = (sngProdprice / 100) * 17.5 'calculate VAT on entered value sngVatcost = Format(sngVatcost, "currency") 'define output as currency lblMessage.Caption = "The VAT cost is £ " & sngVatcost 'output the result lblmessage2.Caption = "Press the start button again to input new number" 'instruction for new number End Sub

11 Private Sub cmdQuit_Click() End 'quit the application End Sub


Download ppt "VAT Calculator program Controls Properties Code Results."

Similar presentations


Ads by Google