Solved

How to link a VB program to the system clock

Posted on 2004-03-25
5
216 Views
Last Modified: 2010-04-17
I am playing arround trying to build a small program that will remind the user when their friends/partiners birthday is comming up. The trouble is in order for it to work propperly I need to be able to link the program to the computers system clock.
Any help will be very welcome.
Harry
0
Comment
Question by:HarrySheehy
5 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 125 total points
ID: 10676882
the two VB functions Date() and Now() both read the system clock

Dim MyDate as Date

MyDate = Date()
MsgBox "Today is " & MyDate, vbOkOnly

MyDate = Now()

MsgBox "It is Now " & MyDate

is that what you are after?

AW
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10676987
Add a timer control to your form...set it's interval to maybe 6000000

How are you relating to the name's and birthdates?

Let's presume you have a string like this:

strInfo="06/06/1955|John Smith,05/01/1970|Stacy Thomas"
(post back if you need to know how to set this up from a text file)

Dim bnotif As Boolean

Private Sub Timer1_Timer()
Dim strinfo As String, strMonth As String, strDay As String, strBDay As String, iPos As Integer

strinfo = "03/25/1955|John Smith,05/01/1970|Stacy Thomas"
strMonth = Format(Month(Date), "00")
strDay = Format(Day(Date), "00")
strBDay = strMonth & "/" & strDay
iPos = InStr(1, strinfo, strBDay)
    If iPos > 0 And Not bnotif Then 'if the date was found and the user hasn't been notified
        iPos = iPos + 11 'start after the found date
        strMsg = Mid(strinfo, iPos, (InStr(1, (Mid(strinfo, iPos)), ",") - 1))
        MsgBox "Today is " & strMsg & "'s Birthday!"
        bnotif = True
    End If
End Sub
0
 
LVL 10

Expert Comment

by:Kavar
ID: 10678916
sounds like you would be much better off using the task scheduler, if you would like to use the task scheduler
tell me if this is vb.net or vb and I will post code for adding tasks
0
 

Author Comment

by:HarrySheehy
ID: 10703422
Arthur Wood, Sirbounty & Kavar,
Many thanks for the help folks. Arthur your code was exactly what I was looking for. Sirbounty & Kavar thanks for your input, but Arthur gets the points this time.
Cheers
Harry
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10703728
glad to be of assistance.

AW
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Report events not being triggered 8 100
commonTwo  challenge 63 100
countX 22 70
When i run adoquery my application freezes 26 100
Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now