CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2001
    Posts
    23

    Running a specific task at specific time of the day

    I am trying to write a program using Timer function and Timer control. I have to send a file everyday through email at 9 am. I do have the code which looks like this:

    Private Sub tmrSaleCode_Timer()
    'MyTime = TimeSerial(10, 19, 0)

    If Start1 = 0 Then
    Start1 = Timer
    End If
    Pause = 86400
    'Pause1 = 1000
    If Timer < Start1 Then
    Start1 = Timer
    End If
    If Timer > (Start1 + Pause1) Then
    'If MyTime = Time Then
    Start1 = Timer

    Module1.TestSndMail
    Label2.Caption = "Last Update = " & Now()
    'Else
    ' Start1 = Timer
    'End If
    End If

    End Sub

    How can I change this to make it work?


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Running a specific task at specific time of the day

    Here is a simple routine using a Timer control that will trigger a hit when the current timeofday = > than your desired time

    option Explicit
    Dim myTime as date


    private Sub Command2_Click()
    myTime = "2:23:00PM"
    print myTime
    Timer1.Interval = 1000 ' one second imtervals
    Timer1.Enabled = true
    End Sub

    private Sub Timer1_Timer()
    If time >= myTime then
    MsgBox "Got a hit"
    Timer1.Enabled = false
    End If
    End Sub




    John G

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

Featured