Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to link a VB program to the system clock

Posted on 2004-03-25
5
Medium Priority
?
224 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Starting up a Project

927 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