Results 1 to 3 of 3

Thread: How can I creat a count down Clock with out using API (If it's need any!)

  1. #1

    Thread Starter
    Hyperactive Member kourosh's Avatar
    Join Date
    Aug 1999
    Location
    Vancouver, British Columbia, Canada
    Posts
    256

    Post

    Hi, I wanted to know how to created a count down clock in a vbform. Forexample if you type 2 (meaning 2 hours) in a text box then you click start, the program start counting down the two hours. Can anybody help me to find a way do this but please don't say anything about API. I have no idea how to use API. Perhaps I should learn it soon.

  2. #2
    New Member
    Join Date
    Oct 1999
    Posts
    14

    Post

    try using a Timer. You can use 2 labels one for the hour one for the minutes. Have the time decriment the minutes by one every minute and have the hours decrement when minutes reach zero.

  3. #3
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Post

    Here, play around with this code. It requires two text boxes, a command button to start countdown, and a timer control. Set the timer Interval to 1000. Good luck!

    Private Sub Timer1_Timer()
    Dim I As Integer
    I = Val(Text2.Text)
    Text2.Text = Format(I - 1, "00")
    If I = 0 Then
    Text2.Text = "59"
    End If
    End Sub


    Private Sub Cmdtime_Click()
    Timer1.Enabled = True
    Text2.Text = "00"
    If (Len(Text1.Text) = 1) Then
    Text1.Text = "0" & Text1.Text
    End If
    If (Len(Text1.Text) = 1) And (Len(Text2.Text) = 2) Then
    Text1.Text = "0" & Text1.Text
    End If
    If Text1.Text = "29" And Text2.Text = "50" Then
    frmtimeup.Show
    End If
    Cmdtime.Enabled = False
    Text1.Locked = True
    Text2.Locked = True
    End Sub

    Private Sub Text2_Change()
    Dim N As Integer
    N = Val(Text1.Text)
    If Text2.Text = "59" Then
    Text1.Text = N - 1
    End If
    If Val(Text2.Text) = 0 And Val(Text1.Text) = 0 Then
    Timer1.Enabled = False
    Message = "Your time is up. "
    buttonsandicons = vbOKOnly + vbInformation
    Title = "Contdown"
    MsgBox Message, buttonsandicons, Title
    End If
    Exit Sub
    End Sub



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width