Solved

Verfiy Date and Time to Trigger

Posted on 1998-12-20
3
140 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 115
VBA saving file message display 5 67
VBA filters 2 61
Access Object Property from VBA Module in Excel 2010 2 31
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

810 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