Timer help needed.

Reply

Join Date: Oct 2005
Posts: 4
Reputation: Y2A is an unknown quantity at this point 
Solved Threads: 0
Y2A Y2A is offline Offline
Newbie Poster

Timer help needed.

 
0
  #1
Oct 15th, 2005
Hey, I was reffered here by a friend and said that you solved his problem.

I am in High School and im doing SDD. I have been asked to design a washing machine user interface.

I have pretty muched finished. I have a timer, which has diffrent times for diffrent settings (eg 1 hours for regular, 45 mins for delicate etc..)

All was going well until i found out i need to add delay times (1 hour, 3, 6, 9 and 12).

Any idea on how i could go about doing that? Im not very good with VB (I am just learning) and I want to get a good mark.

I can put up the work if it would help solve the problem

Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: Timer help needed.

 
0
  #2
Oct 16th, 2005
Yes, post something of what you've done so far, making it a little clearer what you need to do.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 4
Reputation: Y2A is an unknown quantity at this point 
Solved Threads: 0
Y2A Y2A is offline Offline
Newbie Poster

Re: Timer help needed.

 
0
  #3
Oct 17th, 2005
I have 2 timers. Timer1 and Timer2.

I have to add a delay (in this example it's 3 seconds).

so I have a command button that enables Timer2 to count down 3 seconds. When that is done, it should start Timer1.

this is the code.
Private Sub Commandd1h_Click()
txt2Sec.Text = "3"
txt2Min.Text = "0"
txt2Hour.Text = "0"
Timer2.Enabled = True

Do Until txt2Sec.Text = 0 And txt2Min.Text = 0 And txt2Hour.Text = 0
Label10.Visible = True
Loop
Timer1.Enabled = True

End Sub
This freezes my computer.

these are the code to the timers.

Originally Posted by Timer2
Private Sub Timer2_Timer()

If txt2Sec.Text = 0 And txt2Min.Text = 0 And txt2Hour.Text = 0 Then
Timer1.Enabled = False
ElseIf txt2Sec.Text > 0 Then
txt2Sec.Text = txt2Sec.Text - 1
Else 'if zero
txt2Sec.Text = 59

If txt2Min.Text > 0 Then 'update mins
txt2Min.Text = txt2Min.Text - 1
Else
'check if Hour is 0, and if it is, then stop timer, else continue
txt2Min.Text = 59

If txt2Hour.Text > 0 Then 'update mins
txt2Hour.Text = txt2Hour.Text - 1
Else
'check if Hour is 0, and if it is, then stop timer, else continue
txt2Hour.Text = 0
End If

End If

End If
End Sub
Originally Posted by Timer1
Private Sub Timer1_Timer()

If txtSec.Text = 0 And txtMin.Text = 0 And txtHour.Text = 0 Then
Timer1.Enabled = False
ElseIf txtSec.Text > 0 Then
txtSec.Text = txtSec.Text - 1
Else 'if zero
txtSec.Text = 59

If txtMin.Text > 0 Then 'update mins
txtMin.Text = txtMin.Text - 1
Else
'check if Hour is 0, and if it is, then stop timer, else continue
txtMin.Text = 59

If txtHour.Text > 0 Then 'update mins
txtHour.Text = txtHour.Text - 1
Else
'check if Hour is 0, and if it is, then stop timer, else continue
txtHour.Text = 0
End If

End If

End If
THIS IS URGENT
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: Timer help needed.

 
0
  #4
Oct 17th, 2005
If all Timer2 does is count down 3 secs then switch to Timer1 then the code needed would be something like this:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Command1_Click()
  2. txt2Sec.Text = 3
  3. Timer2.Enabled = True
  4. End Sub
  5.  
  6. Private Sub Timer2_Timer()
  7. txt2Sec.Text = txt2Sec.Text - 1
  8.  
  9. If txt2Sec.Text = 0 Then
  10. Timer2.Enabled = False
  11. Timer1.Enabled = True
  12. End If
  13.  
  14. End Sub

First set the Interval property of the two timers to 1000 and the Enabled properties to False, and the text of each textbox to 0.

Also have a look at this thread, should be helpful to you:

http://www.daniweb.com/techtalkforum...ighlight=timer
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC