Solved

How to link a VB program to the system clock

Posted on 2004-03-25
5
217 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

22 Experts available now in Live!

Get 1:1 Help Now