Solved

Verfiy Date and Time to Trigger

Posted on 1998-12-20
3
141 Views
Last Modified: 2010-05-03
I have an app that I want to verify Date and time from a value stored in a text file. dt.txt looks like this

12/20/1998 04:00am
I have a two lables that have captions, one for the Date and one for the Time, I'm using a time to update the caption for the time. I was thinking of haow I could use another time to check the "dt.txt" file and verfiy the captions and when the are the same to popup a msgbox. kind
of like and alarm clock with a calender.  any thoughts?
0
Comment
Question by:rhop
3 Comments
 
LVL 3

Accepted Solution

by:
jbil earned 100 total points
ID: 1451615
'This worked for me

Private Sub Form_Load()
Dim dtstr As String
Open "C:/dt.txt" For Input As #1
'format as 12/20/98 8:53:00 PM
Do While Not EOF(1)
   dtstr = Input(1, #1)
   mystr = mystr & dtstr
Loop

Close #1
'mystr = "12/20/98 8:47:00 PM" 'test str
Me.Show
Label1.Caption = Date
Alarm mystr
End Sub

Private Sub Alarm(ByVal mystr As String)

While Label1.Caption & " " & Label2.Caption <> mystr
    DoEvents
    Label2.Caption = Time
Wend
Beep
mystr = ""

End Sub

0
 
LVL 1

Expert Comment

by:muffinthedog
ID: 1451616
rhop,
    could set a timer on the "DateDiff" of seconds * 1000 like the following to eliminate the loop...

SetTime(DateDiff * 1000)

module level...

Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long

Private hTimer As Long


Sub SetTime(ByVal dwMilliseconds As Long)
    hTimer = SetTimer(0, 0, dwMilliseconds, AddressOf TimerProc)
End Sub

Sub TimerProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal hTimer As Long, ByVal dwTime As Long)
    MsgBox "Do something on event here"
    KillTimer 0, hTimer
End Sub

0
 

Author Comment

by:rhop
ID: 1451617
Thanks for the quick response. You got me going in the right direction.


0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows 10 start screen issues 9 55
MS Date Picker 64 bit 32 bit issue 12 61
TT Auto Dashboard 13 95
Collapse and expand table in Word 2010 2 39
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question