Solved

How to link a VB program to the system clock

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

831 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