CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2012

    Question Help needed with DateTimePicker???

    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!

    HTML Code:
    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
    HTML Code:
     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
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: Help needed with DateTimePicker???

    Look at the return value for DateTimePicker.Month to see WHAT it is.

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Aug 2009
    NW USA

    Re: Help needed with DateTimePicker???

    DateTimePicker is a class. You shouldn't do this:
    Dim DateTimePicker As Date
    I'm trying to see if that variable is even assigned a value. If you have a control that's a DateTimePicker then you only need to reference it by its name (i.e. dtpReservationDate.Month)

  4. #4
    Join Date
    Jul 2012

    Re: Help needed with DateTimePicker???

    Thanks for the help...problem fixed!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.