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

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.

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!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.