Compare 2 long times using vb6

this eub will be called every 10 seconds by a timer

Private Sub TimeCheck
dim TimeDifference as integer
dim TimeNow as ?
dim TaskTime as ?
TaskTime = 0500 '5AM
gintDailyReminder = 2 'from ini file(Hours)
TaskTime = TaskTime - megintDailyReminder

TimeDifference = timenow - gintDailyReminder
If TimeDifference > 2 then exit sub
Select Case TimeDifference
Case 2 
  MsgBox "You need to take your medicine in 2 hours at " & TaskTime 'convert to AM/PM
Case 1
  MsgBox "You need to take your medicine in 1 hour at " & TaskTime 'convert to AM/PM
Case Else
  MsgBox "You Forgot to take your medicine at " & TaskTime 'convert to AM/P
End Select

Open in new window

how can this be done ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
They should probably be Date variables and you should look up and use DateDiff to determine the difference.
Martin LissOlder than dirtCommented:
In other words here is some code. I place a breakpoint on line 6, ran the code, waited a few seconds and then let it run and the Msgbox told me "4".

Dim StartTime As Date
Dim EndTime As Date

StartTime = Now

EndTime = Now

MsgBox DateDiff("s", StartTime, EndTime)

Open in new window

isnoend2001Author Commented:
Thanks Mart, forget my email
I looked at this the datdsiff, but it looked like it worked with dates and not times
working with  long times has got me stumped
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

isnoend2001Author Commented:
Have to run an errand be back in a couple hours
Martin LissOlder than dirtCommented:
What do your "long times" look like.
isnoend2001Author Commented:
1700 = 5Pm
0500 = 5AM
Martin LissOlder than dirtCommented:
Is 1700 a part of the file name that contains the date?
isnoend2001Author Commented:
No it only contains the time
fName = "Dy" & Format(DTPicker1.Value, "HHMM") & ".rtf"
 gives this: Dy1700.rtf
the Dy & .rtf are removed
Martin LissOlder than dirtCommented:
Does this help?

Dim StartTime As Date
Dim EndTime As Date

' These two would not be in your program. They just represent
' the two values you start with.
Const STRING1 = "530"
Const STRING2 = "1700"

' Create a time value from the first character of the string if the string has 3
' characters, or the first two characters if it has 4, plus ":" plus the
' last two characters
StartTime = Left$(STRING1, Len(STRING1) - 2) & ":" & Right$(STRING1, 2)
EndTime = Left$(STRING2, Len(STRING2) - 2) & ":" & Right$(STRING2, 2)

' Subtract the two values and show the difference two ways
MsgBox "The difference is " & Format(EndTime - StartTime, "HH:MM")
MsgBox "or put another way " & Left$(Format(EndTime - StartTime, "HH:MM"), 2) & " Hours and " _
                             & Right$(Format(EndTime - StartTime, "HH:MM"), 2) & " Minutes"

Open in new window

isnoend2001Author Commented:
did not realize this was so envolved
In looking at the code i do not see the comparison to the users system time.
Better explain more this is a reminder that happens every day at a certain time. and has the option
to set a reminder up to 2 hours before the reminder time
For example
Sister has set to take her medicine every morning at 9Am and has set a reminder of 2 hours
so at 7Am 2 hours before 9Am the message "you have to take your medicine in 2 hours"
then again at 8Am "you have to take your medicine in 1 hour" these  pre warnings are optional
Just realized that I cannot tell her to delete the file each day after she takes the medicine. i will have to
make something to flag the  task done
Martin LissOlder than dirtCommented:
Please see and verify my comments in this code. The problem with this code is that you have the potential to get multiple reminder messages depending on how often TimeCheck runs.

Private Sub TimeCheck()
Dim TimeDifference As String
'dim TimeNow as ?
Dim TaskTime As String
Dim dteTaskTime As Date

' I assume that this is defined someplace else so it's
' not needed here
Dim gintDailyReminder As Integer

' I assume that TaskTime is the time at which she needs
' to take her medicine
TaskTime = 900  '9AM
dteTaskTime = Left$(TaskTime, Len(TaskTime) - 2) & ":" & Right$(TaskTime, 2)

' I assume that gintDailyReminder is the number of hours before
' the task time that she should get the first message
gintDailyReminder = 2 'from ini file(Hours)

' What is megintDailyReminder? Did you mean gintDailyReminder?
'TaskTime = TaskTime - megintDailyReminder

TimeDifference = Format(Time() - dteTaskTime, "HH:NN") 'gintDailyReminder
Select Case CInt(Left$(TimeDifference, 2)) - gintDailyReminder
Case Is > 2
    Exit Sub
Case 0
  MsgBox "You need to take your medicine in 2 hours at " & Format(dteTaskTime, "HH:NN AM/PM") 'convert to AM/PM
Case -1
  MsgBox "You need to take your medicine in 1 hour at " & Format(dteTaskTime, "HH:NN AM/PM") 'convert to AM/PM
Case Else
  MsgBox "You Forgot to take your medicine at " & Format(dteTaskTime, "HH:NN AM/PM") 'convert to AM/P
End Select
End Sub

Open in new window

Here's how it would be set up on Google Calendar.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isnoend2001Author Commented:
What is megintDailyReminder? Did you mean gintDailyReminder?
'TaskTime = TaskTime - megintDailyReminder
 yes a typo
I will look into the google calendar. couple things that i have concerns about
Afew years ago i used google phone for long distance which was free and in my gmail, suddenly it was gone so i bought a tracphone.
need a internet connection, last week my sisters was down all day
isnoend2001Author Commented:
Thanks for all your help
Martin LissOlder than dirtCommented:
You don't have to have an internet connection to use Google Mail (lookup Google Offline) and the alerts can be emails rather than or in addition to pop-ups.

How often does TimeCheck run?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.