0

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,

Edited by jbutardo: Added explanation.

4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by poojavb
0

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

0

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

Edited by thines01: added code

0

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

Edited by poojavb: add]

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.