modify a vb6 project

Need modification to this code (see below code)
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


gintDailyReminder may not apply it may be zero then
Case ?
Msgbox "It's time to take your medicine"'no reminder
also need a way to stop the messages when the task is done for each day
I will post the question
is there any way to give bonus points ?
__Time-.zip
isnoend2001Asked:
Who is Participating?
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:
There's no way to give bonus points. The best you can do is to give an "A" grade but that's what's normally done anyhow.

Would a grid or other control on the form where the tasks for the day were listed and a checkbox next to each one that indicates competition be acceptable?
0
isnoend2001Author Commented:
Would a grid or other control on the form where the tasks for the day were listed and a checkbox next to each one that indicates competition be acceptable?
Have to give this more thought. what would the checkbox do?
more concerned with
 gintDailyReminder may not apply it may be zero then
Case ?
Msgbox "It's time to take your medicine"'
also need a way to stop the messages when the task is done for each day
0
Martin LissOlder than dirtCommented:
The column above the reminders would say "Today's Reminders" and the heading above the checkboxes would say "Done" and helpText for it would say "If you've followed up on the reminder, check the box".  

In any case if the box were checked the 1 hour, two hour and/or whatever other warnings were associated with the event could be stopped.

If gintDailyReminder is 0, what do you want to have happen?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

isnoend2001Author Commented:
If gintDailyReminder is 0, what do you want to have happen?
Msgbox "Its time to take your medicine"
There are reminders, and a past due  but missing is
 at the time is is scheduled
there is a reminder 2 hours before and 1 hour before,but nothing at the time it is due.
Are you referring to a msflexgrid?
with each row or rows if more than one scheduled task(s) ?
0
Martin LissOlder than dirtCommented:
Yes I'm referring to an msflexgrid and there would be one row for each task that was due to happen today.

I just thought of something. We've been talking about a file called dy0900.rtf and reminders that say "It's time to take your medicine"'. Surely all the reminders can't be about medicine can they? If not then where are the descriptions of the tasks stored?
0
isnoend2001Author Commented:
Actually The reminder i have made for yearly actually opens the rtf and
the reminders say "You have a task due in 2 days" etc and a labellabel
0
Martin LissOlder than dirtCommented:
I don't understand how you want to use gintDailyReminder so I've set it to 0 in this code. It will only give one notification at 2 hours, 1 hour and pill-taking time. It won't give any notice once your sister indicates she's taken the pills. If she's late it will continue to notify her until they're taken.

Please note line 2 where I've defined a collection for notifications, line 14 where you can try different due times for testing and the 2 new procedures in lines 45 to 65. If you need help understanding how the code works please let me know.

Option Explicit
Private mcolNotifications As New Collection

Private Sub TimeCheck()
Dim lngTimeTotask As Long
Dim strTaskTime As String
Dim dteTaskTime As Date
Dim lngSecondsToDueTime As Long

Dim gintDailyReminder As Integer
strTaskTime = 1426
dteTaskTime = Left$(strTaskTime, Len(strTaskTime) - 2) & ":" & Right$(strTaskTime, 2)

gintDailyReminder = 0 '2 'from ini file(Hours)

' This routine runs every 10 seconds so if we want to produce a message at one
' or two hours before the due time, and produce the message only once then
' we need to look at seconds rather than hours and minutes

' Get the time to the task time in seconds
lngTimeTotask = DateDiff("s", Time(), dteTaskTime)

lngSecondsToDueTime = lngTimeTotask - gintDailyReminder * 3600
Debug.Print lngSecondsToDueTime
Select Case lngSecondsToDueTime
' Over 2 hours
Case Is > 7210
    Exit Sub
' 2 hours to 2 hours and 10 seconds
Case 7200 To 7210
    Notify "You need to take your medicine in 2 hours at " & Format(dteTaskTime, "HH:NN AM/PM") & "." & vbCrLf & _
           "If you do it now, then come back and click 'Yes'.", strTaskTime, vbExclamation
' 1 hour to 1 hour and 10 seconds
Case 3600 To 3610
    Notify "You need to take your medicine in 1 hours at " & Format(dteTaskTime, "HH:NN AM/PM") & "." & vbCrLf & _
           "If you do it now, then come back and click 'Yes'.", strTaskTime, vbExclamation
Case 0 To 10
    Notify "It's time to take your medicine." & vbCrLf & _
           "When you've done that please come back and click 'Yes'.", strTaskTime, vbExclamation
Case Is < 0
    Notify "You Forgot to take your medicine at " & Format(dteTaskTime, "HH:NN AM/PM") & "." & vbCrLf & _
           "Please do it now and then come back and click 'Yes'.", strTaskTime, vbExclamation
End Select
End Sub
Private Sub Notify(strMsg As String, strTaskTime As String, Optional intMsgType As Integer = vbInformation)
    On Error Resume Next
    If Not keyExists(strTaskTime & Format(Now(), "yymmdd")) Then
        If vbYes = MsgBox(strMsg, intMsgType + vbYesNo) Then
              mcolNotifications.Add strTaskTime, strTaskTime & Format(Now(), "yymmdd")
        End If
    End If
    On Error GoTo 0

End Sub
Public Function keyExists(strKey As String) As Boolean
  On Error GoTo ErrorHandler:

  Dim strItem As String

  strItem = mcolNotifications(strKey)
  keyExists = True
  Exit Function
ErrorHandler:
  keyExists = False
End Function
Private Sub Timer1_Timer()
TimeCheck
End Sub

Open in new window

0

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:
Thanks Marty
It will take me some time to look it over, i notice you are basing the time calculation on seconds.
0
Martin LissOlder than dirtCommented:
i notice you are basing the time calculation on seconds.
Yes, that's the only way I could think of to prevent a 2-hour or 1-hour reminder msgbox from appearing every 10 seconds.

BTW you should delete line 24.
0
isnoend2001Author Commented:
Really got a curve thrown to me of coding this
Went wit my sister to the doc today and he prescribed medicine for her to take before bed time.
so now she needs a reminder in the am and pm
0
Martin LissOlder than dirtCommented:
Here are some rtf name suggestions
 ap0800_2000 ' ap = AM & PM
dy2_0800_2000
2d0800-2000

or if the second dose is always 12 hours later you don't need the _2000 part.
0
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.