Welcome to Dream.In.Code
Become an Expert!

Join 136,944 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,869 people online right now. Registration is fast and FREE... Join Now!




Egg Timer

 
Reply to this topicStart new topic

> Egg Timer, More stuff to do with a timer.

sam_benne
Group Icon



post 7 Feb, 2008 - 10:57 AM
Post #1


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.
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

akhileshbc
Group Icon



post 27 Sep, 2008 - 09:24 PM
Post #2
What kind of thing is this man..???? I didn't see anything smile.gif
Go to the top of the page
+Quote Post

sam_benne
Group Icon



post 28 Sep, 2008 - 12:34 AM
Post #3
It changes color when the timer finishes.
Go to the top of the page
+Quote Post

gleeenob
*



post 16 Nov, 2008 - 06:27 AM
Post #4
o-k easy stuff but i need a way to stop the seconds at 60 and then loop again behind the decimal point can u help?

my site ludy.4rumer.com
Go to the top of the page
+Quote Post

sam_benne
Group Icon



post 16 Nov, 2008 - 06:31 AM
Post #5
Do you mean at 60 secs it goes 60.1 60.2 etc? Cos if so you just get it to check if the timer is at 60 then add 0.1.
Go to the top of the page
+Quote Post


Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 12/3/08 11:12PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month