Can anyone help me with a problem I'm having with datetimepickers on my project? I have two on my form, they are used to calculate the amount of days for a car rental
application. I have them coded and they work, the problem is when I change the first date(as in the pickup date) it does not affect the output in the textbox. It will only affect the textbox if I change the second date(the return date). Any way to fix this? Also, is there anyway to prevent a negative amount of days being entered in the textbox? Thanks, Mike.
Here's my code:
Private Sub dtpReturn_ValueChanged(sender As System.Object, e As System.EventArgs) Handles dtpReturn.ValueChanged
'Declare dates
Dim datePickUp As Date
Dim dateReturn As Date
'Declare Integer to store number of days
Dim intDays As Integer
'Assign values from datepickers to variables
datePickUp = dtpPickUp.Text
dateReturn = dtpReturn.Text
intDays = CInt(dateReturn.Date.Subtract(datePickUp.Date).Days)
txtDays.Text = intDays
End Sub
application. I have them coded and they work, the problem is when I change the first date(as in the pickup date) it does not affect the output in the textbox. It will only affect the textbox if I change the second date(the return date). Any way to fix this? Also, is there anyway to prevent a negative amount of days being entered in the textbox? Thanks, Mike.
Here's my code:
Private Sub dtpReturn_ValueChanged(sender As System.Object, e As System.EventArgs) Handles dtpReturn.ValueChanged
'Declare dates
Dim datePickUp As Date
Dim dateReturn As Date
'Declare Integer to store number of days
Dim intDays As Integer
'Assign values from datepickers to variables
datePickUp = dtpPickUp.Text
dateReturn = dtpReturn.Text
intDays = CInt(dateReturn.Date.Subtract(datePickUp.Date).Days)
txtDays.Text = intDays
End Sub