Getting a date from another form

  • Thread starter Thread starter KentL
  • Start date Start date
K

KentL

I have a main form with a textbox for a date. When I click this textbox I
have another form with only a calendar control, an OK button and an Exit
button that I want to open and the user select a date then click ok. I then
want the date that the user selected to be put into this textbox on the main
form. I am new to vb.net, can someone explain how to do this?

Thanks in advance!
Kent
 
You could add a property to the calendar control form that will hold the
date selected in the calendar control. Something similar to the following:
Private _dateSelected As Date

Public ReadOnly Property DateSelected() As Date

Get

Return _dateSelected

End Get

End Property

When the OK button is clicked, set the _dateSelected variable to the
selected date of the calendar control and close the form.

In the main form use ShowDialog() to display the calendar control form and
then retrieve the property: Something like this:
Dim frmCalendar As New Form2
frmCalendar.ShowDialog()

TextBox1.Text = frmCalendar.DateSelected.toString()

Hope this helps,

Mike McClaran
 
Thanks, this has helped a lot!

I still have a problem. When I click the OK button the date field in my
main for has "1/1/0001 12:00:00 AM" in it. So I take it that the date I
selected in the MonthCalendar1 control is not being capture. How do I
do this? I have tried everything I can think of, but no luck. This
VB.NET is a lot different than VB5!

Thanks again!

Kent


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Back
Top