Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'By Greig Strachan 05/11/10
- Option Explicit 'ensures all variables are declared
- Dim intStart As Integer 'Start mileage
- Dim intConsumed As Integer ' Fuel used
- Dim intEnd As Integer 'End mileage
- Dim strReg As String 'Registration number
- Dim strManu As String 'Manufacturer
- Dim strModel As String 'Car model
- Dim intTotal As Integer 'Total amount of miles
- Dim sngTotalFuel As Single 'total fuel consumed
- Dim sngMpl As Single 'Fuel consumption in miles per litre
- Private Sub cmdCalc_Click()
- 'These if statements will make sure there is input
- If (txtCarReg.Text = "") Then
- MsgBox "Please enter a registration number", vbExclamation, "No input"
- Exit Sub
- End If
- If (txtStart.Text = "") Then
- MsgBox "Please enter a start mileage", vbExclamation, "No Input"
- Exit Sub
- End If
- If (txtEnd.Text = "") Then
- MsgBox "Please enter an end mileage", vbExclamation, "No Input"
- Exit Sub
- End If
- If (txtConsumed.Text = "") Then
- MsgBox "Please enter the amount of fuel used", vbExclamation, "No Input"
- Exit Sub
- End If
- intStart = txtStart.Text
- intEnd = txtEnd.Text
- intTotal = intEnd - intStart 'Calculation for total mileage
- txtTotal.Text = intTotal
- intConsumed = txtConsumed.Text
- sngMpl = intTotal / intConsumed 'Calculation for total fuel used
- txtTotalFuel = sngMpl
- End Sub
- Private Sub cmdReset_Click()
- txtStart.Text = ""
- txtEnd.Text = ""
- txtTotal.Text = ""
- txtCarReg.Text = ""
- txtManu.Text = ""
- txtModel.Text = ""
- txtTotalFuel = ""
- txtConsumed = ""
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement