Well come to my Egg Timer tutorial. THis tutorial will show you the asic things you can do with a timer and use them all at once.
For this project you will need:
A label, Timer, Shape and a combo box.
This will be done in four easy steps in one tutorial.
Step one create a new project call prjTimers and create one form called frmEggTimer. If you haven't already created a label and timer do so. In the general declaration section at the top of the code type:
CODE
Dim SecondsCounter As Integer
Dim Boiling As Boolean
Step two, in the form load procedure type:
CODE
Label1.Visible = False
timeLimit = 1
SecondsCounter = timeLimit * 60
'You can Change the Interval to a lower number to make the timer faster
Timer1.Interval = 1000
Timer1.Enabled = True
Boiling = True
Step three double click Timer1 and in the Timer1.timer() procedure type:
CODE
Static NumberofSeconds As Integer
Dim msg As String
'If you wanted you could change the message
msg = "Your egg is ready!"
NumberofSeconds = NumberofSeconds + 1
If Boiling = True Then
'You can Change the color to one you like
Shape1.BackColor = &H40c0&
Boiling = False
Else
'You can Change the color to one you like
Shape1.BackColor = &H4080&
Boiling = True
End If
If NumberofSeconds = SecondsCounter Then
Label1.Visible = True
Label1.Caption = msg
Timer1.Enabled = False
End If
Step four making sure you have your combo box and in Form_Load procedure type:
CODE
Label1.Visible = False
Combo1.AddItem "Soft Boiled"
Combo1.AddItem "Medium Boiled"
Combo1.AddItem "Hard Boiled"
In Combo1_Click procedure type:
CODE
Dim X As String
X = combo1.text
Select Case X
Case "Soft Boiled"
timeLimit = 1
Case "Medium Boiled"
timeLimit = 2
Case "Hard Boiled"
timeLimit = 3
End Select
SecoundsCounter = timeLimit * 60
'You can Change the Interval to a lower number to make the timer faster
Timer1.Interval = 1000
Timer1.Enabled =True
Now you can test this out by pressing F5. I have commented on certain things that you can edit so have fun.
If you have any problems just comment or contact me (sam_benne@hotmail.co.uk) or if you have any questions.