Solved

How to link a VB program to the system clock

Posted on 2004-03-25
5
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
Simple Linear Regression

734 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