13 Replies - 2443 Views - Last Post: 05 March 2012 - 02:38 AM Rate Topic: -----

#1 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

DateTimePicker question in vb.net

Posted 05 March 2012 - 12:26 AM

hi im a beginner in vb.net and im just wondering if DateTimePicker can be edited if you play it for example it is on the current date today march 5,2012 and i am trying to go way back to 1990 for birthdate for example, what im trying to say is make it easy to use not taking time to clicking it on the year 1990, i am currently using vb.net 2008 and mysql express for my db
Is This A Good Question/Topic? 0
  • +

Replies To: DateTimePicker question in vb.net

#2 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 12:48 AM

you mean by code? something like this?
 Dim dt As New DateTime(1990, 3, 5)
        DateTimePicker1.Text = dt.ToString

Was This Post Helpful? 0
  • +
  • -

#3 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 12:51 AM

View Postsela007, on 05 March 2012 - 12:48 AM, said:

you mean by code? something like this?
 Dim dt As New DateTime(1990, 3, 5)
        DateTimePicker1.Text = dt.ToString

yes sir i mean by just typing it when you select the month,date, and year then you would put the desired month, date, and year
Was This Post Helpful? 0
  • +
  • -

#4 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 01:05 AM

it's not very clear to me what you want to do. But if want to set default year for date time picker without clicking than you can use this code
Dim dt As New DateTime(Year as integer, Month as integer, Day as integer)
DateTimePicker1.Text = dt.ToString


or

Dim dt As New DateTime(Year as integer, Month as integer, Day as integer)
DateTimePicker1.Value = dt

Was This Post Helpful? 0
  • +
  • -

#5 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 01:19 AM

I think I get it - you type a month, date and year and it will select accordingly. This is a quick solution that has no error handling but,
Dim d As String = InputBox("Enter date")
Dim m As String = InputBox("Enter month")
Dim y As String = InputBox("Enter Year")
Dim dt As DateTme = New DateTime(Integer.Parse(y), Integer.Parse(m), Integer.Parse(d))
DateTimePicker1.Value = dt


Was This Post Helpful? 0
  • +
  • -

#6 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 01:26 AM

View Postsela007, on 05 March 2012 - 01:05 AM, said:

it's not very clear to me what you want to do. But if want to set default year for date time picker without clicking than you can use this code
Dim dt As New DateTime(Year as integer, Month as integer, Day as integer)
DateTimePicker1.Text = dt.ToString


or

Dim dt As New DateTime(Year as integer, Month as integer, Day as integer)
DateTimePicker1.Value = dt

hmm can't upload photos sir but i think your getting to the point hmmm so hard to explain but im going to try one more time if i use the mouse scroll or arrow key on the keyboard the date and month year would change to my desired user name i have a code in vb6 way way back but i forgot :sweatdrop:
i think were getting to understand each pther sir but im not trying it on my program XD

View PostDimitriV, on 05 March 2012 - 01:19 AM, said:

I think I get it - you type a month, date and year and it will select accordingly. This is a quick solution that has no error handling but,
Dim d As String = InputBox("Enter date")
Dim m As String = InputBox("Enter month")
Dim y As String = InputBox("Enter Year")
Dim dt As DateTme = New DateTime(Integer.Parse(y), Integer.Parse(m), Integer.Parse(d))
DateTimePicker1.Value = dt


where should i put this code sir?
Was This Post Helpful? 0
  • +
  • -

#7 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 01:35 AM

so you want to change date by selecting desired username?
Was This Post Helpful? 0
  • +
  • -

#8 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 204
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 01:35 AM

Im a little confused. So you want to save the trouble of going back in the DateTimePicker and selecting dates from the past, is that right?

if you want to type in the date, my suggestion is to use a MaskedTextbox.
Was This Post Helpful? 0
  • +
  • -

#9 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 01:38 AM

View PostnK0de, on 05 March 2012 - 01:35 AM, said:

Im a little confused. So you want to save the trouble of going back in the DateTimePicker and selecting dates from the past, is that right?

if you want to type in the date, my suggestion is to use a MaskedTextbox.

but the same thing he can do with date time picker, isn't that right?
Was This Post Helpful? 0
  • +
  • -

#10 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 204
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 01:43 AM

That's what I was thinking too. I remember it is possible. I'm not in a place to check it right now. That's why I'm not getting what the OP really wants.
Was This Post Helpful? 0
  • +
  • -

#11 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 01:54 AM

View PostnK0de, on 05 March 2012 - 01:35 AM, said:

Im a little confused. So you want to save the trouble of going back in the DateTimePicker and selecting dates from the past, is that right?

if you want to type in the date, my suggestion is to use a MaskedTextbox.

hmmm here sir i have a DateTimePicker and in it is Monday.March 05,2012 which is the current date today but what i want to do it that when you click the down arrow in it instead of click the arrow which you can select the month and the year i want it to just Monday.March click this and change the month by typing 05 click and type the date 2012 and that also goes with the year and by doing that i could manipulate the day that i want it to be its value for example my birthday i just want to reduce the hassle of click from the birthday in 1990 or anyone who would register their birthday it could be any year , hope its is clear now :bigsmile:

This post has been edited by cj777: 05 March 2012 - 02:08 AM

Was This Post Helpful? 0
  • +
  • -

#12 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 204
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 02:06 AM

you can use UP DOWN keys to select the month and you're able to just type in the date and the year in the DateTimePicker. No hassle at all.
Was This Post Helpful? 1
  • +
  • -

#13 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 02:10 AM

for example: you can put this code in form load event. That will set dt picker automatically to year 1990. Than you only have to change day and month.
   Dim dt As New DateTime(1990, Now.Month, Now.Day)
        DateTimePicker1.Value = dt

Was This Post Helpful? 0
  • +
  • -

#14 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

Re: DateTimePicker question in vb.net

Posted 05 March 2012 - 02:38 AM

View PostnK0de, on 05 March 2012 - 02:06 AM, said:

you can use UP DOWN keys to select the month and you're able to just type in the date and the year in the DateTimePicker. No hassle at all.

oh i see now i get it
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1