I am trying to pass 2 variables check in date and check out date from 2 different date time picker on a form. The goal is two calculate the number of day between the 2 dates.
Here is what I have so far:
From the form:
Public Class FormReservations
'Declare the new objects:
Private TheRegularPriceObject As ClassRegularPrice
Private Sub ButtonCalculateRate_Click(sender As Object, e As EventArgs) Handles ButtonCalculateRate.Click
TheRegularPriceObject = New ClassRegularPrice(DateTimePickerCheckIn.Value.Date.ToString("dd/MM/yyyy"),DateTimePickerCheckOut.Value.Date.ToString("dd/MM/yyyy"))
LabelNumberOfDay.Text = TheRegularPriceObject.CalculateNumberOfDay.ToString()
End If
End Sub
End Class
This is from the class
Public Class ClassRegularPrice
Protected CheckInDateVar As String
Protected CheckOutDateVar As String
Protected NumberOfDaySpan As Integer
'Constructor:
Public Sub New(ByVal CheckInDateConst As String, ByVal CheckOutDateConst As String)
CheckInDate = CheckInDateConst
CheckOutDate = CheckOutDateConst
CalculateNumberOfDay()
End Sub
Property CheckInDate() As Date
Get
Return CheckInDateVar
End Get
Set(ByVal Value As Date)
CheckInDateVar = Value
End Set
End Property
Property CheckOutDate() As Date
Get
Return CheckOutDateVar
End Get
Set(ByVal Value As Date)
CheckOutDateVar = Value
End Set
End Property
Sub
'Methods:
Sub CalculateNumberOfDay()
NumberOfDaySpan = (CheckOutDateVar - CheckInDateVar)
End Sub
It is not returning a value and I'm not sure I converted my date to string also, but this is what I have been told to do. I am not sure from there how the calculation should work since this is a string... Any help would be greatly appreciated.:)