#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Help with adding tax to certain dates??


    The only part of my project that is not working is the DateTimePickerArrival and DateTimePickerDeparture. I'm trying to add a 10% High Season Rate for the months December-February. Right now it is adding the tax to all days. Any help would be appreciated. Thanks!

    Public Sub SetMyCustomFormat()
    ' Set the Format type and the CustomFormat string.
    DateTimePickerArrival.Format = DateTimePickerFormat.Custom
    DateTimePickerArrival.CustomFormat = "MM dd, yyyy"
    DateTimePickerDeparture.Format = DateTimePickerFormat.Custom
    DateTimePickerDeparture.CustomFormat = "MM dd, yyyy"
    End Sub

    Private Sub AccommodationsTotalButton_Click(sender As System.Object, e As System.EventArgs)Handles AccommodationsTotalButton.Click
    Dim StudioDecimal, OneBedroomDecimal, TwoBedroomDecimal, ThreeBedroomDecimal As Decimal
    Dim DateTimePicker As Date

    'Find the price.
    If StudioRadioButton.Checked Then
    StudioDecimal = STUDIO_OFF_Decimal
    ElseIf OneBedroomRadioButton.Checked Then
    OneBedroomDecimal = ONE_BEDROOM_CONDO_OFF_Decimal
    ElseIf TwoBedroomRadioButton.Checked Then
    TwoBedroomDecimal = TWO_BEDROOM_CONDO_OFF_Decimal
    ElseIf ThreeBedroomRadioButton.Checked Then
    ThreeBedroomDecimal = THREE_BEDROOM_CONDO_OFF_Decimal
    ElseIf StudioOnRadioButton.Checked Then
    StudioDecimal = STUDIO_ON_Decimal
    ElseIf OneBedroomOnRadioButton.Checked Then
    OneBedroomDecimal = ONE_BEDROOM_CONDO_ON_Decimal
    ElseIf TwoBedroomOnRadioButton.Checked Then
    TwoBedroomDecimal = TWO_BEDROOM_CONDO_ON_Decimal
    ElseIf ThreeBedroomOnRadioButton.Checked Then
    ThreeBedroomDecimal = THREE_BEDROOM_CONDO_ON_Decimal
    End If

    'Display the prices.
    StudioTextBox.Text = CStr(StudioDecimal)
    StudioTextBox.Text = StudioDecimal.ToString("C")
    OneBedroomTextBox.Text = CStr(OneBedroomDecimal)
    OneBedroomTextBox.Text = OneBedroomDecimal.ToString("C")
    TwoBedroomTextBox.Text = CStr(TwoBedroomDecimal)
    TwoBedroomTextBox.Text = TwoBedroomDecimal.ToString("C")
    ThreeBedroomTextBox.Text = CStr(ThreeBedroomDecimal)
    ThreeBedroomTextBox.Text = ThreeBedroomDecimal.ToString("C")

    'Calculate the total Accommodation Price.
    Dim AccommodationDecimal As Decimal = CDec(100.0) ' Amount = 100 $
    Dim HIGH_SEASON_RATE_Decimal As Decimal = CDec(10.0) ' Rate = 10%
    AccommodationDecimal = StudioDecimal + OneBedroomDecimal + TwoBedroomDecimal + ThreeBedroomDecimal

    'Calculate the total Accommodation Price with High Season.
    If DateTimePicker.Month < 3 OrElse DateTimePicker.Month > 11 Then
    AccommodationDecimal = CDec(AccommodationDecimal + (HIGH_SEASON_RATE_Decimal * 0.01 * AccommodationDecimal))
    End If

    AccommodationsTotalTextBox.Text = AccommodationDecimal.ToString("C")
    AccommodationDecimal = CDec(CDec(CDbl(AccommodationsTotalTextBox.Text) * CDbl(VacationDaysTextBox.Text)) * CDbl(NumberPeopleTextBox.Text))
    TotalTextBox.Text = AccommodationDecimal.ToString("C")


    End Sub
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    289
    Rep Power
    45
    Would this work?

    If DateTimePicker.Month > 2 and DateTimePicker.Month < 12 Then
    'Do nothing
    Else
    AccommodationDecimal = CDec(AccommodationDecimal + (HIGH_SEASON_RATE_Decimal * 0.01 * AccommodationDecimal))
    End If

    J.A. Coutts
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0
    I figured out my problem...thanks!!


    Originally Posted by couttsj
    Would this work?

    If DateTimePicker.Month > 2 and DateTimePicker.Month < 12 Then
    'Do nothing
    Else
    AccommodationDecimal = CDec(AccommodationDecimal + (HIGH_SEASON_RATE_Decimal * 0.01 * AccommodationDecimal))
    End If

    J.A. Coutts

IMN logo majestic logo threadwatch logo seochat tools logo