W moim kodu poniżej, w jaki sposób skonfigurować arrivaldate i depaturedate więc mogę otrzymać należność? Muszę je ustawić, ponieważ dni pozostały w hotelu, więc mogę wymyślić sumę. Jeśli to ma jakiś sens? Używam datetimickerów w Visual Basic.Jak znaleźć liczbę dni między dwiema datami/DateTimePickers
Public Class RentalForm
'declare constants
Const tax_rate_decimal As Decimal = 12.25D
Const king_price_decimal As Decimal = 110.9D
Const queen_price_decimal As Decimal = 105.9D
Const double_price_decimal As Decimal = 95.9D
'declare variables
Private roomchargesumdecimal, taxamountsumdecimal, amountduesumdecimal As Decimal
Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
Close()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxnameofguest.TextChanged
End Sub
Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
'dimension local variables
Dim numberofguestsinteger As Integer
Dim roomchargedecimal, taxamountdecimal, amountduedecimal, taxratedecimal As Integer
Dim arrivaldate, departuredate As Date
Try
'dates
arrivaldate = Now
'convert quantity to numeric
numberofguestsinteger = Integer.Parse(TextBoxNumberofguests.Text)
'calculate values for single person
roomchargedecimal = numberofguestsinteger * (arrivaldate + departuredate)
taxratedecimal = roomchargedecimal * tax_rate_decimal
Catch ex As Exception
End Try
End Sub
Private Sub DateTimePickerarrivaldate_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePickerarrivaldate.ValueChanged
End Sub
Private Sub Label16averagelengthofstay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label16averagelengthofstay.Click
End Sub
Private Sub RentalForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Możliwy duplikat [Oblicz różnicę między dwiema datami (liczba dni)?] (Https://stackoverflow.com/questions/1607336/calculate-difference-between-two-dates-number-of-days) –