Hi,

I have this textbox that has been inputted by date in the format of MMM-yy using a datetimepicker.

TEXTBOX Jan-11

Now I need to get the exact date on the textbox to be inserted in a string.

string1 = Cdate(txtbox1.text.trim)

but in this code, the inputted text on the textbox can only be converted into MM-dd format

string = Cdate(txtbox1.text.trim) = 01-11-2012

meaning the -11 in the Jan-11 is converted as day,

Now I want to get this as the year.

Can someone help me with this?

Thanks,

If your string is always going to be of the format MMM-yy then you can split it on the '-' character and reform it as you require it

How can you assume the value of the year?
...otherwise, you can split the string
...or...

Public Class Form1
   Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
      Dim strYear As String = ""
      strYear = DateTimePicker1.Value.Year
      MessageBox.Show(strYear)
   End Sub
End Class

if ur format is MMM-yyyy then u will get the output correctly....but the date will be wrong...it will be the first of the month...

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.