Page 1 of 1

Egg Timer More stuff to do with a timer. Rate Topic: -----

#1 sam_benne  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 16
  • View blog
  • Posts: 732
  • Joined: 16-January 08

Posted 07 February 2008 - 11:57 AM

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:
	Dim SecondsCounter As Integer
	Dim Boiling As Boolean



Step two, in the form load procedure type:
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:
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:
Label1.Visible = False
	Combo1.AddItem "Soft Boiled"
	Combo1.AddItem "Medium Boiled"
	Combo1.AddItem "Hard Boiled"


In Combo1_Click procedure type:
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.

Is This A Good Question/Topic? 0
  • +

Replies To: Egg Timer

#2 akhileshbc  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 179
  • Joined: 27-September 08

Posted 27 September 2008 - 10:24 PM

What kind of thing is this man..???? I didn't see anything :)
Was This Post Helpful? 0
  • +
  • -

#3 sam_benne  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 16
  • View blog
  • Posts: 732
  • Joined: 16-January 08

Posted 28 September 2008 - 01:34 AM

It changes color when the timer finishes.
Was This Post Helpful? 0
  • +
  • -

#4 gleeenob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-November 08

Posted 16 November 2008 - 07:27 AM

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
Was This Post Helpful? 0
  • +
  • -

#5 sam_benne  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 16
  • View blog
  • Posts: 732
  • Joined: 16-January 08

Posted 16 November 2008 - 07:31 AM

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.
Was This Post Helpful? 0
  • +
  • -

#6 sandiso  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-September 12

Posted 26 September 2012 - 05:55 AM

Dim SecondsCounter As Integer
Dim Boiling As Boolean

Private Sub Combo1_Change()
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

End Sub

Private Sub Form_Load()
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
Label1.Visible = False
    Combo1.AddItem "Soft Boiled"
    Combo1.AddItem "Medium Boiled"
    Combo1.AddItem "Hard Boiled"

End Sub

Private Sub Timer1_Timer()
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


End Sub



This is my code, I placed a shape,combo box, label,timer.

But when I run it, nothing is happening,I can see items in combo box but nothing is going on. Nothing is happening if I select any item from combo box. please Tell me what I am doing wrong ?
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9498
  • View blog
  • Posts: 35,845
  • Joined: 12-June 08

Posted 26 September 2012 - 06:47 AM

@sandiso: Your events seem to be missing the "handles... " bit on the end.

e.g.: Private Sub Form_Load() handles <... missing event hook up here ...>
Was This Post Helpful? 0
  • +
  • -

#8 sandiso  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-September 12

Posted 26 September 2012 - 07:17 AM

View Postmodi123_1, on 26 September 2012 - 06:47 AM, said:

@sandiso: Your events seem to be missing the "handles... " bit on the end.

e.g.: Private Sub Form_Load() handles <... missing event hook up here ...>

Sorry, I didnt understand what u said. I have been learning vb6 bit by bit but never seen handles in any prog.
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9498
  • View blog
  • Posts: 35,845
  • Joined: 12-June 08

Posted 26 September 2012 - 07:21 AM

Snap.. never mind.. this is vb6.. not .NET.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1