convert date to ticks?

S

sparkle

Hi,

Does anybody know how to convert date to ticks from a dateTimePicker?
What I'm using now isn't working.

I'm trying to use a dateTimePicker to set an appointment in Outlook
with a reminder. I need this reminder to remind the recipient 14 days
in advance.

I'm having problems with the ReminderMinutesBeforeStart. If I simply
multiply the minutes by the days, the reminder doesn't have the
checkbox checked or it is checked, but with 0 minutes. As if it can't
figure out that many minutes.

I've written some code to do this for me, but with the same results
(checkbox in the reminder set to 0 minutes).

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dim oApp As Outlook.Application = New Outlook.Application
Dim lDays As Long
Dim lMinutes As Long

lMinutes = DaysToMinutes(lDays)

' Create a new AppointmentItem.
Dim oAppt As Outlook.AppointmentItem =
oApp.CreateItem(Outlook.OlItemType.olAppointmentItem)

oAppt.Subject = "Parking Permits Will expire in two weeks"
oAppt.Body = "Let Employees with Parking Permits know the
expiration date is two weeks away"
oAppt.Location = "Watsonville"
oAppt.Start = Convert.ToDateTime(dtpExpired.Value)
oAppt.End = Convert.ToDateTime(dtpExpired.Value)
oAppt.ReminderSet = True
oAppt.ReminderMinutesBeforeStart = lMinutes

' Save to Calendar.
oAppt.Save()

' Clean up.
oApp = Nothing
oAppt = Nothing

End Sub

Function DaysToMinutes(ByVal days As Long) As Long
Return days =20160
End Function

End Class

Does anybody know if the TimeStamp would work better for subtracting
days? If so, how do I convert the date to ticks?

Here is a TimeSpan string that could be used to show negative values:
"[-]14:00:00:00", but this is using ticks...

Thanks,
 
S

Sven Groot

sparkle said:
Return days =20160

I don't know it this is your problem or just a typo in the post, but that
should obviously not be an equals sign. It would return zero as you
described, since 'days=20160' equals false.
 
C

Cor Ligthert

Hi Sparkle,

Why are you sending such a large piece of code that has nothing to do with
this.
Does anybody know how to convert date to ticks from a dateTimePicker?

Simple questions are eays to answer however when the rest of the text seems
to have no relation with the question you mostly get no answer. Here is a
direct answer on your question where I added 14 days in advance)

Dim InTicksDatePlusFourteen As Long = _
CDate(DateTimePicker1.Text).AddDays(14).Ticks

I hope this helps?

Cor
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed)-cruz.ca-dot-us.no-spam.invalid (sparkle) scripsit:
Does anybody know how to convert date to ticks from a dateTimePicker?
What I'm using now isn't working.

'Me.DateTimePicker1.Value.Ticks'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top