Home All Groups Group Topic Archive Search About
Author
7 Apr 2005 7:57 AM
patang
Question 1
I have two forms, let say Form1 and Form2. There is datetimepicker control
on Form2. In the Load Event of Form2 I have set the default value of
datetimepicker control to NOW.  So as expected when I open the form the
default value is set to today's date. Now I sometimes also call Form2 from
Form1. Ok now here is my problem. Actually when I call Form2 from within
Form1 I want to set the set the value of datetimepicker control to something
else. I have written following code to call form2 from form1 and setting the
value of datetimepicker control:

Dim frm As Form2
frm = New Form2
frm.dtbDOB.value = "1 / 1 / 2005"
frm.showdialog()

I know this is happeneing because when I call form2 from form1, even though
I am setting the value of dtbDOB control but it is overwritten by the value
set in Load Event.

What should I do ?

Question 2
What is the purpose of Text property of DateTimePicker Control ?

Question 3.
How come I don't see the Text property in the properties window, however
when I create an instanace of an form and if that form has datetimepicker
control then I can the Text property

frm.dtpDOB.Text

Thanks in advance.

Author
7 Apr 2005 8:21 AM
patang
Question 3.

What do we do when the user don't want to set any date and the control is
datetimepicker. How do you set null value  in this case because if we use
datetimepicker control we are requried  to choose the date.

Show quoteHide quote
"patang" wrote:

> Question 1
> I have two forms, let say Form1 and Form2. There is datetimepicker control
> on Form2. In the Load Event of Form2 I have set the default value of
> datetimepicker control to NOW.  So as expected when I open the form the
> default value is set to today's date. Now I sometimes also call Form2 from
> Form1. Ok now here is my problem. Actually when I call Form2 from within
> Form1 I want to set the set the value of datetimepicker control to something
> else. I have written following code to call form2 from form1 and setting the
> value of datetimepicker control:
>
> Dim frm As Form2
> frm = New Form2
> frm.dtbDOB.value = "1 / 1 / 2005"
> frm.showdialog()
>
> I know this is happeneing because when I call form2 from form1, even though
> I am setting the value of dtbDOB control but it is overwritten by the value
> set in Load Event.
>
> What should I do ?
>
> Question 2
> What is the purpose of Text property of DateTimePicker Control ?
>
> Question 3.
> How come I don't see the Text property in the properties window, however
> when I create an instanace of an form and if that form has datetimepicker
> control then I can the Text property
>
> frm.dtpDOB.Text
>
> Thanks in advance.
Author
7 Apr 2005 8:26 AM
Peter Proost
Show quote Hide quote
"patang" <pat***@discussions.microsoft.com> schreef in bericht
news:E30273EB-D9E2-4F47-87C1-0374E309BE0C@microsoft.com...
> Question 1
> I have two forms, let say Form1 and Form2. There is datetimepicker control
> on Form2. In the Load Event of Form2 I have set the default value of
> datetimepicker control to NOW.  So as expected when I open the form the
> default value is set to today's date. Now I sometimes also call Form2 from
> Form1. Ok now here is my problem. Actually when I call Form2 from within
> Form1 I want to set the set the value of datetimepicker control to
something
> else. I have written following code to call form2 from form1 and setting
the
> value of datetimepicker control:
>
> Dim frm As Form2
> frm = New Form2
> frm.dtbDOB.value = "1 / 1 / 2005"
> frm.showdialog()
>
> I know this is happeneing because when I call form2 from form1, even
though
> I am setting the value of dtbDOB control but it is overwritten by the
value
> set in Load Event.
>
> What should I do ?
>
> Question 2
> What is the purpose of Text property of DateTimePicker Control ?
>
> Question 3.
> How come I don't see the Text property in the properties window, however
> when I create an instanace of an form and if that form has datetimepicker
> control then I can the Text property
>
> frm.dtpDOB.Text
>
> Thanks in advance.
Author
7 Apr 2005 8:30 AM
Peter Proost
To answer your first question:
switch places

frm.showdialog()
frm.dtbDOB.value = "1 / 1 / 2005"

to answer question number 2:
try:
MsgBox(dtbDOB.Text)

to answer question number 3, in a datetimepicker control there always is a
date, you can't make it empty as far is I know.

hth Peter



Show quoteHide quote
"patang" <pat***@discussions.microsoft.com> schreef in bericht
news:E30273EB-D9E2-4F47-87C1-0374E309BE0C@microsoft.com...
> Question 1
> I have two forms, let say Form1 and Form2. There is datetimepicker control
> on Form2. In the Load Event of Form2 I have set the default value of
> datetimepicker control to NOW.  So as expected when I open the form the
> default value is set to today's date. Now I sometimes also call Form2 from
> Form1. Ok now here is my problem. Actually when I call Form2 from within
> Form1 I want to set the set the value of datetimepicker control to
something
> else. I have written following code to call form2 from form1 and setting
the
> value of datetimepicker control:
>
> Dim frm As Form2
> frm = New Form2
> frm.dtbDOB.value = "1 / 1 / 2005"
> frm.showdialog()
>
> I know this is happeneing because when I call form2 from form1, even
though
> I am setting the value of dtbDOB control but it is overwritten by the
value
> set in Load Event.
>
> What should I do ?
>
> Question 2
> What is the purpose of Text property of DateTimePicker Control ?
>
> Question 3.
> How come I don't see the Text property in the properties window, however
> when I create an instanace of an form and if that form has datetimepicker
> control then I can the Text property
>
> frm.dtpDOB.Text
>
> Thanks in advance.
Author
7 Apr 2005 1:27 PM
Chris Dunaway
This won't work

>>frm.showdialog()
>>frm.dtbDOB.value = "1 / 1 / 2005"

The showdialog method will not return until the form is closed.  The
code above will set the date *after* the form is closed.
Author
7 Apr 2005 8:33 AM
Crouchie1998
1) You cannot count. You said 2 questions & you asked 3.

-------------------------------------------------

Start New Windows Application

Add new Form (Form2)

In form1 add a button & double-click it

In the click event of the button, type:

Dim frm As New Form2
frm.ShowDialog(DateTime.Now.AddDays(2))
frm.Dispose()

Open form 2 & add a DateTimePicker control

Switch to code view of form 2 & type this:

Public Overloads Function ShowDialog(ByVal dtDate As Date)
DateTimePicker1.Text = dtDate
MyBase.ShowDialog()
End Function
------------------------
When you click the button in form1, it will show the DateTimePicker with
todays date + 2 dayes. You just need to mess around with the values as you
wish.

Question 2) See above (form2 function code)

Question 3) Maybe when Microsft coded it they decided that they wanted to
set that particular property to Browsable (False). If you try & set the Text
property to anything other than a date, it will error. So, the text property
is meant for dates only. I guess that is why.

Lastly, I have attached the sample project to this post

Crouchie1998
BA (HONS) MCP MCSE

[attached file: WindowsApplication1.zip]
Author
7 Apr 2005 8:49 AM
Larry Lard
patang wrote:
Show quoteHide quote
> Question 1
> I have two forms, let say Form1 and Form2. There is datetimepicker
control
> on Form2. In the Load Event of Form2 I have set the default value of
> datetimepicker control to NOW.  So as expected when I open the form
the
> default value is set to today's date. Now I sometimes also call Form2
from
> Form1. Ok now here is my problem. Actually when I call Form2 from
within
> Form1 I want to set the set the value of datetimepicker control to
something
> else. I have written following code to call form2 from form1 and
setting the
> value of datetimepicker control:
>
> Dim frm As Form2
> frm = New Form2
> frm.dtbDOB.value = "1 / 1 / 2005"
> frm.showdialog()
>
> I know this is happeneing because when I call form2 from form1, even
though
> I am setting the value of dtbDOB control but it is overwritten by the
value
> set in Load Event.
>
> What should I do ?

One suggestion:

In Form2 declarations:

Private InitialValue As Date = Now

In Form2_Load:

dtp.Value = InitialValue

In Form2:

    Public Sub MyShowDialog(ByVal ShowValue As Date)
        InitialValue = ShowValue
        Me.ShowDialog()
    End Sub

Then from elsewhere, if you have f2 As Form2, you can either

f2.ShowDialog()  'to get the default of Now
or
f2.MyShowDialog(SomeOtherDate())   'to start with some other date


>
> Question 2
> What is the purpose of Text property of DateTimePicker Control ?

>From the help:

The string returned by this property is equivalent to the Value
property with the appropriate formatting or custom formatting applied.
For example, if the Value property is set to 06/01/2001 12:00:00 AM
while the CustomFormat property is set to "dddd, MMMM dd, yyyy", the
Text property value is "Friday, June 01, 2001".

When setting this property, the string must be convertible to an
instance of the DateTime class. It is possible to define a custom
format that results in a string that cannot be converted to a valid
DateTime value. Because of this, the string returned from the Text
property might cause an error if it is passed back to the Text
property. If the string cannot be converted to a date/time value, the
DateTime class throws a FormatException.


>
> Question 3.
> How come I don't see the Text property in the properties window,
however
> when I create an instanace of an form and if that form has
datetimepicker
> control then I can the Text property
>
> frm.dtpDOB.Text

The Text property of the DateTimePicker has its Browsable attribute set
to No. Which might not mean much to you: basically, when you (or in
this case Microsoft) create a control, you can set attributes of the
properties to determine things like, does it appear in the properties
window, what UI it displays in the properties window, what its default
should be, and so on. In this case, since the Text of a DTP is a purely
dervied value, it makes sense to hide it from the Properties window.


>
> Thanks in advance.

--
Larry Lard
Replies to group please
Author
7 Apr 2005 8:52 AM
Crouchie1998
Basically Larry, you have just repeated what I said earlier. What was the
point of repeat posting? Please read the answers to the post before adding
the same info in future.

Crouchie1998
BA (HONS) MCP MCSE
Author
7 Apr 2005 9:55 AM
Larry Lard
Crouchie1998 wrote:
> Basically Larry, you have just repeated what I said earlier. What was
the
> point of repeat posting? Please read the answers to the post before
adding
> the same info in future.
>
> Crouchie1998
> BA (HONS) MCP MCSE

So many letters and yet such litle understanding of how Usenet works.

btw, the post to which I am replying is the only one by you in this
thread currently visible to me; therefore as far as *I* can tell, 'what
[you] said earlier' Is Nothing.

--
Larry Lard
Replies to group please
Author
7 Apr 2005 10:01 AM
Crouchie1998
Larry,

I am using Outlook Express to post info. What about you? I see the results
as soon as they are posted. If you use the Internet way you can still press
the 'Refresh' button

BTW: Not only do I have the letters, but I have the experience to go with
them

Crouchie1998
BA (HONS) MCP MCSE
Author
7 Apr 2005 10:50 AM
Larry Lard
Crouchie1998 wrote:
> Larry,
>
> I am using Outlook Express to post info. What about you? I see the
results
> as soon as they are posted. If you use the Internet way you can still
press
> the 'Refresh' button

It's not surprising that *you* see messages you post to *your* news
server immediately. However, not everyone is using *your* news server.

part of the news.newusers.questions faq:

(begin excerpt)
: Do all the messages travel to a central site and then all the sites
: that want it, pick it up there?

No, there is no "central" server on Usenet. A newsgroup article
propagates from one server to another, starting from the server where
it is first posted.

: Do all the messages travel to all the sites?

Ideally, all the article in a newsgroup travel to all sites (news
servers) that carry the newsgroup. This means that when you post an
article, the final result is tens of thousands of copies, all over the
world.

More specifically, when you post an article, it goes first to your
"local" news server (operated by your Internet service provider,
company, or school). Your server then sends copies of the article to
its "neighbors," that is, to servers with which it has agreed to
exchange articles. Those servers in turn send copies to *their*
neighbors. Eventually every server that carries the newsgroup has a
copy.

: In what order?

Most servers normally send articles to other servers more or less in
the order of arrival. This sequence can get scrambled for various
reasons, which is why you often see responses before the "original"
article arrives.
(end excerpt)

You might also enjoy
<http://members.fortunecity.com/nnqweb/nquote.html>

--
Larry Lard
Replies to group please
Author
7 Apr 2005 9:58 AM
Oenone
Crouchie1998 wrote:
> Basically Larry, you have just repeated what I said earlier. What was
> the point of repeat posting? Please read the answers to the post
> before adding the same info in future.

Your reply certainly hasn't made it to my news server, and checking Google
Groups, it hasn't made it there either. Are you sure you sent it?

For a group populated by people that are supposed to be helping one another,
I have found your replies to be unnecessary and rude on several occasions.
Posting to these groups is not a competition, there aren't prizes awarded to
the first person to respond.

I'm also not aware of you having been elected as the newsgroup police force.

Please try to be more tolerant of other people's messages. Everyone that
responds on here has invested their own personal time in a selfless attempt
to help someone else that has a problem. No one deserves to be met with your
opinionated judgements on whether or not their post was justified.

--

(O) e n o n e