isnoend2001
asked on
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
how can this be done ?
They should probably be Date variables and you should look up and use DateDiff to determine the difference.
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)
ASKER
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
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
ASKER
Have to run an errand be back in a couple hours
What do your "long times" look like.
ASKER
1700 = 5Pm
0500 = 5AM
0500 = 5AM
Is 1700 a part of the file name that contains the date?
ASKER
No it only contains the time
fName = "Dy" & Format(DTPicker1.Value, "HHMM") & ".rtf"
gives this: Dy1700.rtf
the Dy & .rtf are removed
fName = "Dy" & Format(DTPicker1.Value, "HHMM") & ".rtf"
gives this: Dy1700.rtf
the Dy & .rtf are removed
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"
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
'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
ASKER
Forgot
Thanks for all your help
Thanks for all your help
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?
How often does TimeCheck run?