baconandeggs
Programmer
baconandeggs (Programmer)
Jan 6, 2001
Hello everyone
Can anyone straighten me out on a Select Case Statement for a timer
Overview:
I have a form which has a circle crossed by 4 lines and filled bright yellow to resemble the SUN, a label asks for the correct passsword to be entered and a label to the right which has a yellow background say's [LIGHT ON] which pulses to the same time that the SUN pulses
Current code only pulses at 3 second intervals.
The criteria I am using is this:
Lightstate = 0 Light on for 3 seconds
Lightstate = 1 and 3 light off 1 second
Lightstate = 2 and 4 Light on for 1 second
Lightstate = 5 Light off 3 seconds
can you set the correct interval for the timer
best regards
Jim
[small]
'In the general declarations part of the Form Code window, DECLARE A VARIABLE
Dim LightState As Integer
Dim Kount As Integer
Private Sub cmdClose_Click()
Unload Me
'stop the timer
tmrLight.Enabled = False
'Reset integer variables
Kount = 0
LightState = 0
End
End Sub
Private Sub Form_Load()
Me.Caption = "PAOS " & "" & "James Kennedy " & "" & "20th December 2000 "
'make the signalling lamp components invisible on startup
ShpRay_1.Visible = False
ShpRay_2.Visible = False
ShpRay_3.Visible = False
ShpRay_4.Visible = False
ShpFlash.Visible = False
lblLight.Visible = False
Kount = 0
'Set initial Variable Value
LightState = 5
End Sub
Private Sub lblLight_Click()
End Sub
Private Sub tmrlight_Timer()
Kount = Kount + 1
lblSecondCount = Kount
Select Case LightState
Case 0
ShpRay_1.Visible = False
ShpRay_2.Visible = False
ShpRay_3.Visible = False
ShpRay_4.Visible = False
ShpFlash.Visible = False
lblLight.Visible = False
If Kount = 3 Then
ShpRay_1.Visible = True
ShpRay_2.Visible = True
ShpRay_3.Visible = True
ShpRay_4.Visible = True
ShpFlash.Visible = True
lblLight.Visible = True
txtPassword.Visible = True
txtPassword.BackColor = &HFFFFFF
txtPassword.SetFocus
Kount = 0
tmrLight.Enabled = True
End If
Case 1
If Kount = 0 Then
ShpRay_1.Visible = True
ShpRay_2.Visible = True
ShpRay_3.Visible = True
ShpRay_4.Visible = True
ShpFlash.Visible = True
lblLight.Visible = True
End If
If Kount = 1 Then
ShpRay_1.Visible = False
ShpRay_2.Visible = False
ShpRay_3.Visible = False
ShpRay_4.Visible = False
ShpFlash.Visible = False
lblLight.Visible = False
End If
If Kount > 2 Then
ShpRay_1.Visible = True
ShpRay_2.Visible = True
ShpRay_3.Visible = True
ShpRay_4.Visible = True
ShpFlash.Visible = True
txtPassword.Visible = True
txtPassword.BackColor = &HFFFFFF
txtPassword.SetFocus
tmrLight.Enabled = True
Kount = 0
End If
Case 2
If Kount = 0 Then
ShpRay_1.Visible = False
ShpRay_2.Visible = False
ShpRay_3.Visible = False
ShpRay_4.Visible = False
ShpFlash.Visible = False
lblLight.Visible = False
End If
If Kount = 1 Then
ShpRay_1.Visible = True
ShpRay_2.Visible = True
ShpRay_3.Visible = True
ShpRay_4.Visible = True
ShpFlash.Visible = True
lblLight.Visible = True
End If
If Kount > 2 Then
ShpRay_1.Visible = False
ShpRay_2.Visible = False
ShpRay_3.Visible = False
ShpRay_4.Visible = False
ShpFlash.Visible = False
lblLight.Visible = False
txtPassword.Visible = False
txtPassword.BackColor = &HFFFFFF
txtPassword.SetFocus
tmrLight.Enabled = False
Kount = 0
End If
Case 5
If Kount = 0 Then
ShpRay_1.Visible = True
ShpRay_2.Visible = True
ShpRay_3.Visible = True
ShpRay_4.Visible = True
ShpFlash.Visible = True
lblLight.Visible = True
End If
If Kount = 1 Then
ShpRay_1.Visible = False
ShpRay_2.Visible = False
ShpRay_3.Visible = False
ShpRay_4.Visible = False
ShpFlash.Visible = False
lblLight.Visible = False
End If
If Kount > 3 Then
ShpRay_1.Visible = True
ShpRay_2.Visible = True
ShpRay_3.Visible = True
ShpRay_4.Visible = True
ShpFlash.Visible = True
lblLight.Visible = True
txtPassword.Visible = True
txtPassword.BackColor = &HFFFFFF
txtPassword.SetFocus
tmrLight.Enabled = True
Kount = 0
End If
End Select
End Sub
Private Sub txtPassword_Change()
Dim I As Integer, num As Single
If txtPassword.Text = "nrg" _
Or txtPassword.Text = "Nrg" _
Or txtPassword.Text = "NRG" Then
'for the correct password use green as signal
txtPassword.BackColor = &HC000&
Else
If txtPassword.Text <> "nrg" _
Or txtPassword.Text <> "Nrg" _
Or txtPassword.Text <> "NRG" Then
'change the colour of the text to red as a signal but use hexadecimal
txtPassword.BackColor = &HFF&
End If
'set a 1 second delay
For I = 1 To 20000
'let the processor do some work
num = 10000 / 5000
Next
txtPassword.Text = ""
'hide txtpassword
txtPassword.Visible = True
'Show lblLight
lblLight.Visible = True
'start timer
tmrLight.Enabled = True
Exit Sub
End If
End Sub
[/small]