|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
2 easy questionsI 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. 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.
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. 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. This won't work
>>frm.showdialog() The showdialog method will not return until the form is closed. The>>frm.dtbDOB.value = "1 / 1 / 2005" code above will set the date *after* the form is closed. 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] patang wrote:
Show quoteHide quote > Question 1 One suggestion:> 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 ? 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 > The string returned by this property is equivalent to the Value> Question 2 > What is the purpose of Text property of DateTimePicker Control ? >From the help: 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. > The Text property of the DateTimePicker has its Browsable attribute set> 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 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 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 Crouchie1998 wrote:
> Basically Larry, you have just repeated what I said earlier. What was So many letters and yet such litle understanding of how Usenet works.the > point of repeat posting? Please read the answers to the post before adding > the same info in future. > > Crouchie1998 > BA (HONS) MCP MCSE 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 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 Crouchie1998 wrote:
> Larry, It's not surprising that *you* see messages you post to *your* news> > 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 server immediately. However, not everyone is using *your* news server. >From <http://members.fortunecity.com/nnqweb/how-it-works.html> which is part of the news.newusers.questions faq:(begin excerpt) : Do all the messages travel to a central site and then all the sites No, there is no "central" server on Usenet. A newsgroup article: that want it, pick it up there? 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 (newsservers) 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 inthe 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 Crouchie1998 wrote:
> Basically Larry, you have just repeated what I said earlier. What was Your reply certainly hasn't made it to my news server, and checking Google> the point of repeat posting? Please read the answers to the post > before adding the same info in future. 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
How to convert hex to string?
Difference between Trim function and Trim member New To Imaging How to get form design view back? DateTimePicker Bug? How to create a Serialnumber for App programmatically? Using MSCOMM32.ocx with VB.net Can I pass value from VB form to VBS? sending string thru TCP/IP SharpZipLib & Blocked File |
|||||||||||||||||||||||