Marie-Andree
Member
- Joined
- Sep 9, 2015
- Messages
- 8
- Programming Experience
- Beginner
Hello,
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:
This my class:
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.
[/COLOR]
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:
VB.NET:
[COLOR=#00008B]Public[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Class[/COLOR][COLOR=#000000] FormReservations
[/COLOR][COLOR=#808080]'Declare the new objects:[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Private[/COLOR][COLOR=#000000] TheRegularPriceObject [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] ClassRegularPrice
[/COLOR][COLOR=#00008B]Private[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Sub[/COLOR][COLOR=#000000] ButtonCalculateRate_Click[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]sender [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Object[/COLOR][COLOR=#000000],[/COLOR][COLOR=#000000] e [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] EventArgs[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Handles[/COLOR][COLOR=#000000] ButtonCalculateRate[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000]Click
TheRegularPriceObject [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]New[/COLOR][COLOR=#000000] ClassRegularPrice[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]DateTimePickerCheckIn[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000]Value[/COLOR][COLOR=#000000].[/COLOR][COLOR=#00008B]Date[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000]ToString[/COLOR][COLOR=#000000]([/COLOR][COLOR=#800000]"dd/MM/yyyy"[/COLOR][COLOR=#000000]),[/COLOR][COLOR=#000000]DateTimePickerCheckOut[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000]Value[/COLOR][COLOR=#000000].[/COLOR][COLOR=#00008B]Date[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000]ToString[/COLOR][COLOR=#000000]([/COLOR][COLOR=#800000]"dd/MM/yyyy"[/COLOR][COLOR=#000000]))[/COLOR][COLOR=#000000]
LabelNumberOfDay[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000]Text [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#000000] TheRegularPriceObject[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000]CalculateNumberOfDay[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000]ToString[/COLOR][COLOR=#000000]()[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]End[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]If[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]End[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Sub
[COLOR=#222426][FONT=Arial]End Class
[/FONT][/COLOR]
This my class:
VB.NET:
[COLOR=#00008B]Public[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Class[/COLOR][COLOR=#000000] ClassRegularPrice
[/COLOR][COLOR=#00008B]Protected[/COLOR][COLOR=#000000] CheckInDateVar [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]String[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Protected[/COLOR][COLOR=#000000] CheckOutDateVar [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]String[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Protected[/COLOR][COLOR=#000000] NumberOfDaySpan [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Integer[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#808080]'Constructor: [/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Public[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Sub[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]New[/COLOR][COLOR=#000000]([/COLOR][COLOR=#00008B]ByVal[/COLOR][COLOR=#000000] CheckInDateConst [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]String[/COLOR][COLOR=#000000],[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]ByVal[/COLOR][COLOR=#000000] CheckOutDateConst [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]String[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]
CheckInDate [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#000000] CheckInDateConst
CheckOutDate [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#000000] CheckOutDateConst
CalculateNumberOfDay[/COLOR][COLOR=#000000]()[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]End[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Sub[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Property[/COLOR][COLOR=#000000] CheckInDate[/COLOR][COLOR=#000000]()[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Date[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Get[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Return[/COLOR][COLOR=#000000] CheckInDateVar
[/COLOR][COLOR=#00008B]End[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Get[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Set[/COLOR][COLOR=#000000]([/COLOR][COLOR=#00008B]ByVal[/COLOR][COLOR=#000000] Value [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Date[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]
CheckInDateVar [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#000000] Value
[/COLOR][COLOR=#00008B]End[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Set[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]End[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Property[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Property[/COLOR][COLOR=#000000] CheckOutDate[/COLOR][COLOR=#000000]()[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Date[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Get[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Return[/COLOR][COLOR=#000000] CheckOutDateVar
[/COLOR][COLOR=#00008B]End[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Get[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Set[/COLOR][COLOR=#000000]([/COLOR][COLOR=#00008B]ByVal[/COLOR][COLOR=#000000] Value [/COLOR][COLOR=#00008B]As[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Date[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]
CheckOutDateVar [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#000000] Value
[/COLOR][COLOR=#00008B]End[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Set[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]End[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Property[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Sub[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#808080]'Methods:[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]Sub[/COLOR][COLOR=#000000] CalculateNumberOfDay[/COLOR][COLOR=#000000]()[/COLOR][COLOR=#000000]
NumberOfDaySpan [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#000000] [/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]CheckOutDateVar [/COLOR][COLOR=#000000]-[/COLOR][COLOR=#000000] CheckInDateVar[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#00008B]End[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00008B]Sub[/COLOR]
[/COLOR]