none
Countdown Timer (Auto Reset) and Timer Clock (Auto Change)

All replies

  • Hi raj441977,

      I am sorry that I could completely understand the scenario that you said. If possible, could you give me the more information about it? In other words, Could you give us your code arround it?

      Sincerely,

      Jason Wang


    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us


    Wednesday, April 18, 2012 2:47 AM
  • Hi Jason Wang,

    I am new in programming, just completed my course but cant get overall from there. So i am confused to start the project, actually cant decide where to start or which code is to be apply.

    1. & 2. is easy for me

    3. & 4. Automatically change scheduled time and schedule product to next when last countdown reaches time. (09:00:00, 09:05:00, 09:10:00)

    5. Calculate the time difference from a scheduled time to current time (in hh:mm:ss format) left.(00:05:00, 00:04:59, 00:04:58)

    All countdown and time calculation is related with 1. & 2. (with actual time)

    All scheduled Product and Time is in Access Database.

    Thursday, April 19, 2012 10:20 AM
  • Public Class Form1

        Dim stpw As New Stopwatch, cntDwn As New TimeSpan(0, 5, 0)


        Private Sub Form1_Load_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Activated

            If Not stpw.IsRunning Then
                'start the countdown
                stpw.Reset()
                stpw.Start()
                Timer1.Interval = 1000
                Timer1.Start()
            Else

            End If
        End Sub

        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

            Dim togo As TimeSpan = cntDwn - stpw.Elapsed
            If CInt(togo.TotalMilliseconds) <= 0 Then
                stpw.Start()
            Else
                Timer1.Interval = 1000
                Label2.Text = String.Format("{0:00}:{1:00}:{2:00}", togo.Hours, togo.Minutes, togo.Seconds)
                Label1.Text = DateTime.Now.ToLongTimeString
            End If
        End Sub

    End Class

    Label2.text is starting countdown when application starting and it is not matching with System time, I want a countdown timer which will initialize System time and it will count for 09:05:00 and then for 09:10:00 and then for 09:15:00 .............., and it will start automatically

    plz help

    Saturday, April 28, 2012 2:03 PM
  • Thanks for friendship,,...........here is my code................. ========================================= Imports System.Data.SqlClient
    Imports System.Data.SqlClient.SqlException
    Imports System.Data.OleDb

    Public Class Form1
    Dim DrawTime As DateTime = DateTime.Parse("09:00:00 AM")
    Dim endTime As DateTime = DateTime.Parse("11:00:00 PM")

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Label1.Text = DateTime.Now.ToLongTimeString
    Label2.Text = DrawTime.ToLongTimeString
    Label3.Text = endTime.ToLongTimeString

    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

    If DateTime.Compare(DateTime.Now, DrawTime) > 0 Then
    DrawTime = DateAdd(DateInterval.Minute, 1, DrawTime)
    End If
    If DateTime.Compare(endTime, DateTime.Now) < 0 Then
    DrawTime = DateTime.Parse("09:00:00 AM")
    End If
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim connection As New OleDbConnection(("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Time.mdb;Persist Security Info=True;User ID=admin;Jet OLEDB:Database Password=admin"))
    Try
    connection.Open()
    MsgBox("Local Database is OK")
    connection.Close()
    Catch ex As Exception
    MsgBox("Database Not Ready")
    End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim Con As SqlConnection
    Dim cons As String
    cons = "Data Source=STAR-FC923986DB\SQLEXPRESS;Initial Catalog=starsql;Persist Security Info=True;User ID=sa;Password=raju@441977;"
    Con = New SqlConnection(cons)
    Try
    Con.Open()
    MsgBox("Server Connection is Open ! ")
    Con.Close()
    Catch ex As Exception
    MsgBox("Sorry Can not open connection ! ")
    End Try
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    Dim connection As New OleDbConnection(("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Time.mdb;Persist Security Info=True;User ID=admin;Jet OLEDB:Database Password=admin"))
    Try
    connection.Open()
    Label1.Show()
    connection.Close()
    Catch ex As Exception
    MsgBox("Database Not Ready")
    End Try
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

    Dim connection As New OleDbConnection(("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Time.mdb;Persist Security Info=True;User ID=admin;Jet OLEDB:Database Password=admin"))
    Try
    connection.Open()
    Dim command1 As New OleDbCommand(("SELECT DrawTime FROM AllDraw"), connection)
    Label2.Text = DrawTime
    Label2.Show()
    If DateTime.Compare(DateTime.Now, DrawTime) > 0 Then
    Dim command2 As New OleDbCommand(("SELECT DrawTime FROM AllDraw, MOVE NEXT"), connection)
    Label2.Text = DrawTime
    Label2.Show()
    End If
    connection.Close()
    Catch ex As Exception
    MsgBox("Database Not Ready")
    End Try
    End Sub

    End Class                              ========================================= Login or connection to Database (Local or SQL) is OK but how can I get Proper DrawTime which is just ahead from Current system time from 500 + row of DrawTime which is given in Local or SQL Database
    Sunday, April 29, 2012 12:12 PM