954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

DateTimePicker.Value from TextBox, String

My form has a TextBox with values like(e.g: P011112, C0212102) those are products lot numbers that the user enters. Then, what i want is that a DateTimePicker takes the first 4 digits as "MM-yyyy" and add 3 years to that date.

Example: TextBox.text = P011112
DateTimePicker = January, 2014


Thanks in advance

pipelian
Newbie Poster
4 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 
Dim prod As String = "P011112"

Dim mm As Integer = CInt(prod.Substring(1, 2))
Dim yy As Integer = CInt(prod.Substring(3, 2))

MsgBox(MonthName(mm, False) & ", " & yy + 2003)    'output is "January, 2014"


Assumes that the digits in the string are valid for conversion to date.

Reverend Jim
Posting Shark
Moderator
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
 
Dim prod As String = "P011112"

Dim mm As Integer = CInt(prod.Substring(1, 2))
Dim yy As Integer = CInt(prod.Substring(3, 2))

MsgBox(MonthName(mm, False) & ", " & yy + 2003)    'output is "January, 2014"

Assumes that the digits in the string are valid for conversion to date.


Awesome...thank you so much!!

pipelian
Newbie Poster
4 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: