Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

passing dates from the calender to text box

Posted on 2005-04-11
5
Medium Priority
?
150 Views
Last Modified: 2011-09-20
I have a calendar control on the form by name MonthCalendar1

I have two text boxes. I'm trying to pass two dates like start and end date into the text boxes 1 and 2. For that I did like this

Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
        txtstartdate.Text = MonthCalendar1.SelectionStart
        txtenddate.text = MonthCalendar1.Selectionend
end sub

BUT WHEN I SELECT THE FIRST TIME IT COPIES TO BOTH TEXTBOXES. HOW TO GET THE SECOND SELECTION DATE TO SECOND TEXTBOX.

Thanks
VM
0
Comment
Question by:vmandem
  • 2
  • 2
5 Comments
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13756146
try using the DateSelected event instead

"This event is similar to DateChanged, but it occurs at the end of a date selection made using the mouse. The DateChanged event occurs during any date selection, whether by mouse, keyboard, or code."
0
 

Author Comment

by:vmandem
ID: 13756475
BriCrowe,

It does the same. No change

VM
0
 
LVL 13

Expert Comment

by:Torrwin
ID: 13756593
I just use two calendar controls.  One for the start date, and one for the end date.
0
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 100 total points
ID: 13756692
try this...

private startDate as boolean = true

Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
    If startDate Then
        txtstartdate.Text = MonthCalendar1.SelectionStart
        startDate = false
    Else
        txtenddate.text = MonthCalendar1.Selectionend
        startDate = true
   End If
end sub
0
 

Author Comment

by:vmandem
ID: 13758589
BriCrowe

This one works fine, what If I want to change the firstdate through the calender. The above code changes only for second date. I'm disabling the textboxes for the users to edit and choose only from calendar.

Thanks
VM
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

804 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question