VS 2008 Month Calender help-VBForums
Results 1 to 8 of 8

Thread: Month Calender help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2013
    Posts
    79

    Month Calender help

    I have a button1 that when clicked, it opens a monthcalendar1 form. I would like to have the user select a date from the calendar and whatever date they selected shows up in the a textbox but in "yyMMdd" format. On some forums I've read, its states that if I want just the date and not the range I need to change the MaxSelectionCount=1 in the properties window and use the "monthcalendar.selectionend" in my code. Unfortunately no example of code was given. I'm not so worried about the date format right now but just getting it into the textbox. Any help greatly appreciated. Running visual studio 2010 in windows 7 if it helps.

  2. #2
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: Month Calender help

    Just call

    vbnet Code:
    1. MonthCalendar1.SelectionRange.Start.ToString("yyMMdd")

    also assign MaxSelectionCount = 1
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2013
    Posts
    79

    Re: Month Calender help

    Thanks for the quick response. I'm sorry but I've should of started off by saying I'm new at programming with visual basic. How do link that to the textbox. All this is under the public class???? Where would this code be entered, the button1.click, monthCalendar1 or form1.load. Maxselection is already = 1.
    Last edited by pooky; Mar 1st, 2013 at 12:03 AM.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,241

    Re: Month Calender help

    TextBox1.Text = MonthCalendar1.SelectionRange.Start.ToString("yyMMdd")
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: Month Calender help

    Quote Originally Posted by pooky View Post
    Where would this code be entered, the button1.click, monthCalendar1 or form1.load. Maxselection is already = 1.
    You'll want to take what dunfiddlin suggested and place it in your method that handles the buttons click event.
    vbnet Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.     ' Update the text every time the user clicks this button.
    3.     TextBox1.Text = MonthCalendar1.SelectionRange.Start.ToString("yyMMdd")
    4. End Sub
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Feb 2013
    Posts
    79

    Re: Month Calender help

    That worked. Thank you both very much for your help. Problem solved.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2013
    Posts
    79

    Re: Month Calender help

    Quick question. If I wanted to use this form to work with another form what would I need to add to this code? Would I have to embed it within a public class. For example:

    Public Class txtDate.Text = MonthCalendar1.SelectionRange.Start.ToString("yyMMdd")
    End Class

    Would these two lines of code be entered in on the form with the calendar or on the form it'll be used in? Hope that made sense.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Feb 2013
    Posts
    79

    Re: Month Calender help

    It worked. Thank you so very much for your help.

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

Survey posted by VBForums.