AutoGuide




Option Explicit
Dim HourMinSec
Dim Odometer
Dim Tenth
Sub chkLights_Click ()
'Update Status

UpdateTxt
'Turn Lights On

If chkLights.Value = 1 Then lblLight1.BackColor = _
QBColor(14) Else lblLight1.BackColor = QBColor(15)
If chkLights.Value = 1 Then lblLight2.BackColor = _
QBColor(14) Else lblLight2.BackColor = QBColor(15)
End Sub

Sub chkRadio_Click ()
'Update Status

UpdateTxt
End Sub

Sub chkWipers_Click ()
'Update Status

UpdateTxt
End Sub

Sub cmdCarOff_Click ()
'Turn Idler Off

If HourMinSec = 1 Then HourMinSec = 0
'Update Engine Status

txtCarOnOff.Text = "Car: OFF"
End Sub

Sub cmdCarOn_Click ()
'Start Idler and Car

If HourMinSec = 0 Then HourMinSec = 1
'Update Engine Status

txtCarOnOff.Text = "Car: ON"
End Sub

Sub cmdEnd_Click ()
'End Program

End
End Sub

Sub Form_Load ()
'Load On English Measurement

optEnglish.Value = True
'Load Alert Color

lblGasAlert.ForeColor = QBColor(15)
End Sub

Sub Form_MouseDown (Button As Integer, Shift As Integer, _
X As Single, Y As Single)
'Reset Accelerator to 0

If txtCarOnOff.Text = "Car: OFF" Then _
vsbAccelerator.Value = 0
'Increase Accelerator

If (Button And 1) = 1 Then _
vsbAccelerator.Value = vsbAccelerator.Value + 1
'Decrease Accelerator

If (Button And 2) = 2 Then _
vsbAccelerator.Value = vsbAccelerator.Value - 1
'Stop Accelerator at 120

If vsbAccelerator.Value = 121 Then _
vsbAccelerator.Value = vsbAccelerator.Value - 1
'Stop Decelerator at 0

If vsbAccelerator.Value = -1 Then _
vsbAccelerator.Value = vsbAccelerator.Value + 1
'Add MPH to Speedometer

txtSpeedometer.Text = vsbAccelerator.Value + " MPH"
'Reset Speedometer

If txtCarOnOff.Text = "Car: OFF" Then _
txtSpeedometer.Text = "0 MPH"
End Sub

Sub Form_MouseMove (Button As Integer, Shift As Integer, _
X As Single, Y As Single)
'Reset Accelerator to 0

If txtCarOnOff.Text = "Car: OFF" Then _
vsbAccelerator.Value = 0
'Increase Accelerator

If (Button And 1) = 1 Then _
vsbAccelerator.Value = vsbAccelerator.Value + 1
'Decrease Accelerator

If (Button And 2) = 2 Then _
vsbAccelerator.Value = vsbAccelerator.Value - 1
'Stop Accelerator at 120

If vsbAccelerator.Value = 121 Then _
vsbAccelerator.Value = vsbAccelerator.Value - 1
'Stop Decelerator at 0

If vsbAccelerator.Value = -1 Then _
vsbAccelerator.Value = vsbAccelerator.Value + 1
'Add MPH to Speedometer

txtSpeedometer.Text = vsbAccelerator.Value + " MPH"
'Reset Speedometer

If txtCarOnOff.Text = "Car: OFF" Then _
txtSpeedometer.Text = "0 MPH"
End Sub

Sub Form_MouseUp (Button As Integer, Shift As Integer, _
X As Single, Y As Single)
'Reset Accelerator to 0

If txtCarOnOff.Text = "Car: OFF" Then _
vsbAccelerator.Value = 0
'Increase Accelerator

If (Button And 1) = 1 Then _
vsbAccelerator.Value = vsbAccelerator.Value + 1
'Decrease Accelerator

If (Button And 2) = 2 Then _
vsbAccelerator.Value = vsbAccelerator.Value - 1
'Stop Accelerator at 120

If vsbAccelerator.Value = 121 Then _
vsbAccelerator.Value = vsbAccelerator.Value - 1
'Stop Decelerator at 0

If vsbAccelerator.Value = -1 Then _
vsbAccelerator.Value = vsbAccelerator.Value + 1
'Add MPH to Speedometer

txtSpeedometer.Text = vsbAccelerator.Value + " MPH"
'Reset Speedometer

If txtCarOnOff.Text = "Car: OFF" Then _
txtSpeedometer.Text = "0 MPH"
End Sub

Sub hsbGas_Change ()
'Display Contents of tank

If txtCarOnOff.Text = "Car: OFF" Then hsbGas.Value = 1000
'Display Alert

If hsbGas.Value < 100 Then lblGasAlert.ForeColor = QBColor(12)
If hsbGas.Value < 100 Then Beep
If hsbGas.Value > 100 Then lblGasAlert.ForeColor = QBColor(15)
'Add label to caption

lblGas.Caption = hsbGas.Value + " Gallons"
'Turn car off when tank reaches 0

If hsbGas.Value = 0 Then txtCarOnOff.Text = "Car: OFF"
'Turn Idler off

If hsbGas.Value = 0 Then HourMinSec = 0
End Sub

Sub hsbGas_Scroll ()
If txtCarOnOff.Text = "Car: OFF" Then hsbGas.Value = 1000
If hsbGas.Value < 100 Then lblGasAlert.ForeColor = QBColor(12)
If hsbGas.Value < 100 Then Beep
If hsbGas.Value > 100 Then lblGasAlert.ForeColor = QBColor(15)
lblGas.Caption = hsbGas.Value + "Gallons"
End Sub

Sub optEnglish_Click ()
'Update Status

UpdateTxt
End Sub

Sub optMetric_Click ()
'Update Status

UpdateTxt
End Sub

Sub tmrTimer1_Timer ()
'Car Idler

If HourMinSec = 1 Then Beep
End Sub

Sub tmrTimer2_Timer ()
'Decrease and stop gas gauge

If hsbGas.Value = 0 Then _
hsbGas.Value = hsbGas.Value - 0 Else _
hsbGas.Value = hsbGas.Value - 1
End Sub

Sub tmrTimer3_Timer ()
'Update Odometer

If optEnglish.Value = True Then _
Odometer = Odometer + (tmrTimer3.Interval * _
vsbAccelerator.Value / 3600000)
If optMetric.Value = True Then _
Odometer = Odometer + (tmrTimer3.Interval * _
vsbAccelerator.Value / 10000000)
txtOdometer.Text = Format$(Odometer, "#######.0")
End Sub

Sub tmrTimer4_Timer ()
'Display System Time

If txtClock.Text <> CStr(Time) Then txtClock.Text = Time
End Sub

Sub txtCarOnOff_Change ()
'Stop gas gauge

If txtCarOnOff.Text = "Car: OFF" Then _
tmrTimer2.Enabled = False
End Sub

Sub txtOdometer_Change ()
'Restrict Odometer Output To tenths

Tenth = Odometer * 10
Tenth = Int(Tenth)
Tenth = Tenth / 10
End Sub

Sub UpdateTxt ()
Dim Info
If chkLights.Value = 1 Then Info = "Lights: ON" Else _
Info = "Lights: OFF"
If chkWipers.Value = 1 Then Info = Info + Chr(13) + _
"Wipers: ON" Else Info = Info + Chr(13) + "Wipers: OFF"
If chkRadio.Value = 1 Then Info = Info + Chr(13) + _
"Radio: ON" Else Info = Info + Chr(13) + "Radio: OFF"
If optEnglish.Value = True Then Info = Info + Chr(13) + _
"Measurement: English"
If optMetric.Value = True Then Info = Info + Chr(13) + _
"Measurement: Metric"
txtStatus.Caption = Info
End Sub











( autoguide.html )- by Paolo Puglisi - Modifica del 17/12/2023