isnoend2001
asked on
Working with datepicker values vb6
i am trying to this, but it does not work
If mydate > Now Then'this does not work
'start tomorrow
'MsgBox "Notifactions will start tomorrow," WeekdayName & Format(DTPicker1.Value, "HH:MM AM/PM") & " and continue everyday"
'Else
'start today
MsgBox "Reminder will notify at " & Format(DTPicker1.Value, "HH:MM AM/PM") & " Today and continue everyday" '12 hr time"
End If
the date picker value to test with
Debug.Print DTPicker1.Value produces this: 10/3/2015 7:00:00 PM
If mydate > Now Then'this does not work
'start tomorrow
'MsgBox "Notifactions will start tomorrow," WeekdayName & Format(DTPicker1.Value, "HH:MM AM/PM") & " and continue everyday"
'Else
'start today
MsgBox "Reminder will notify at " & Format(DTPicker1.Value, "HH:MM AM/PM") & " Today and continue everyday" '12 hr time"
End If
the date picker value to test with
Debug.Print DTPicker1.Value produces this: 10/3/2015 7:00:00 PM
ASKER
Debug.Print DTPicker1.Value produces this: 10/3/2015 7:00:00 PM
mydate = DTPicker1.Value
i willtest your code
mydate = DTPicker1.Value
i willtest your code
ASKER
no matter what time i select it only does the else
MsgBox "Reminder will appear at " & Format(DTPicker1.Value, "HH:MM AM/PM") & " today and will continue everyday" '12 hr time"
MsgBox "Reminder will appear at " & Format(DTPicker1.Value, "HH:MM AM/PM") & " today and will continue everyday" '12 hr time"
What is in mydate?
ASKER
Private Sub Command_Click()
Dim mydate As Date
Dim mydate As Date
I meant - what is the value when the code runs?
ASKER
here is everything
Private Sub Command_Click()
Dim mydate As Date
Dim myDay As Integer
' Dim fName As String
mydate = DTPicker1.Value
If mydate > Now Then
'start tomorrow
MsgBox "Notifications will start tomorrow, " & Format(DateAdd("d", 1, Now), "dddd") & ", at " _
& Format(DTPicker1.Value, "HH:MM AM/PM") & " and will continue everyday"
Else
'start today
MsgBox "Reminder will appear at " & Format(DTPicker1.Value, "HH:MM AM/PM") & " today and will continue everyday" '12 hr time"
End If
also
the tomorrow date need to add 1 day to the date
Private Sub Command_Click()
Dim mydate As Date
Dim myDay As Integer
' Dim fName As String
mydate = DTPicker1.Value
If mydate > Now Then
'start tomorrow
MsgBox "Notifications will start tomorrow, " & Format(DateAdd("d", 1, Now), "dddd") & ", at " _
& Format(DTPicker1.Value, "HH:MM AM/PM") & " and will continue everyday"
Else
'start today
MsgBox "Reminder will appear at " & Format(DTPicker1.Value, "HH:MM AM/PM") & " today and will continue everyday" '12 hr time"
End If
also
the tomorrow date need to add 1 day to the date
Did you actually choose 10/17? I did and it works for me with this code (you don't need mydate; you can always use the vales of controls directly).
Private Sub Command1_Click()
If DTPicker1.Value > Now Then
'start tomorrow
MsgBox "Notifications will start tomorrow, " & Format(DateAdd("d", 1, Now), "dddd") & ", at " _
& Format(DTPicker1.Value, "HH:MM AM/PM") & " and will continue everyday"
Else
'start today
MsgBox "Reminder will appear at " & Format(DTPicker1.Value, "HH:MM AM/PM") & " today and will continue everyday" '12 hr time"
End If
End Sub
However if you choose a date after tomorrow, the message will still say "tomorrow". what do you want it to say?
Oh I see! You have time in the datepicker. Let me try that and see what I can do.
ASKER
ok
This works but there's a problem I think.
Private Sub Command1_Click()
If DateDiff("h", DTPicker1.Value, Now) > 1 Then
'start tomorrow
MsgBox "Notifications will start tomorrow, " & Format(DateAdd("d", 1, Now), "dddd") & ", at " _
& Format(DTPicker1.Value, "HH:MM AM/PM") & " and will continue everyday"
Else
'start today
MsgBox "Reminder will appear at " & Format(DTPicker1.Value, "HH:MM AM/PM") & " today and will continue everyday" '12 hr time"
End If
End Sub
The problem is this. Let's say it's 7:19 PM here (which it is) if I use the up button on the dtpicker to get to, say, 10PM I get the "tomorrow" message. If however I use the down button until it shows 10PM I get the "today" message.
ASKER
yes there is something wrong
time now 7:52
datepicker time 10:00pm
message says tomorrow, but it should say today
time now 7:52
datepicker time 10:00pm
message says tomorrow, but it should say today
As I said, you can get to 10PM by going up or down. If you sister chooses 10PM, no matter which way she gets there, do you always want to say "tomorrow"?
If so change the first line to
Note: Don't add the "AM/PM" to that line.
If Format(DTPicker1.Value, "HH:MM") > Format(Now, "HH:MM") Then
Note: Don't add the "AM/PM" to that line.
ASKER
No if the datepicker time is later than the pc time the it should say today
Then change the > to a <.
ASKER
Yes it's backwards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Could you post the code instead of a image of the code ?
ASKER
Thanks marty got it, never relized dates/times was so difficult
Open in new window