How to code a datetimepicker with the datediff control

Tags:
DATEDIFF
DateTimePicker
I need to code a button's click even so that it will calculate the number of days between a selected date by the user in the datetimepicker and today. I then need to subtract that number from a number entered by the user in a text box.
' declar the date and time variables
        Dim d1 As DateTimePicker
        Dim d2 As Date = Today
        Dim dblPill As Double
        Dim dblPres As Double
        Dim d3 As Long
        Dim dblRemain As Double
        ' declare value of each variable
        dblPill = txtNumberOfPills.Text
        dblPres = txtNumberOfRefills.Text
        d1 = DateTimePicker1

        ' determine number of days between selected date and today
        d3 = DateDiff(DateInterval.Day, d1, d2, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1)

        ' calculate number of remaining pills based on 
        ' number of pills times refills and then subtracting the number of days 
        dblRemain = dblPill * dblPres - d3
        ' display remaining pills in label
lblDisplayRemainingPills.Text = dblRemain
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: