dcsimg
Results 1 to 5 of 5

Thread: Calenders Help!

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    5

    Thumbs up Calenders Help!

    So...i can put a calender on a form and do the code to allow you select a start date, end date, and calculate the amount of days you are staying somewhere.

    But for my project i have to restrict the calender so that the customer cannot enter a date that has already expired...but i dont have a clue how to do this!

    Ny ideas??!!

  2. #2
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Calenders Help!

    Two assumptions:

    1. You are using the MonthView not the Calendar control.
    2. By "expired" you mean in the past.

    If so, try this
    Code:
    Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
    If DateClicked < Format(Now, "mm/dd/yyyy") Then
       MsgBox "Invalid Date.  Can not be earlier than today."
    Else
       Text1.Text = DateClicked
    End If
    End Sub
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  3. #3
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,335

    Re: Calenders Help!

    Quote Originally Posted by emeros89
    So...i can put a calender on a form and do the code to allow you select a start date, end date, and calculate the amount of days you are staying somewhere.

    But for my project i have to restrict the calender so that the customer cannot enter a date that has already expired...but i dont have a clue how to do this!

    Ny ideas??!!
    I don't know what kind of calendar control you are using and what you mean by "expired" date. I just threw this together for a month view but it should work on what you are doing.

    In the GotFocus capture the date currently displayed. On the click event check it and put it back to what it was.

    Code:
    Option Explicit
    Private dMonthViewValue As Date
    
    Private Sub Form_Load()
    
        'MonthView.Value = What ever it needs to be to start.
    
    End Sub
    
    Private Sub MonthView_DateClick(ByVal DateClicked As Date)
        
        If Format(MonthView.Value, "YYYYMMDD") < Format(Now(), "YYYYMMDD") Then
            MsgBox "Can't use prior date"
            MonthView.Value = dMonthViewValue
        End If
    
        
    End Sub
    
    Private Sub MonthView_GotFocus()
    
        dMonthViewValue = MonthView.Value
    
    End Sub

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    5

    Re: Calenders Help!

    Thanks well, is its the Microsoft Calendar Control 12.0,

    Sorry, by expired i meant dates already past so if today is nov. 6th then you cant choose Nov. 5th / 4th etc

  5. #5
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,335

    Re: Calenders Help!

    What I posted should work for you then.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width