Format text

  • Thread starter Thread starter Jimmy
  • Start date Start date
J

Jimmy

How can i format text, so that user input such as,
01062004 would be formatted as 01/06/2004. I've tried
several user-defined number and date formats, but I seem
to be missing something.

Thank you.
 
* "Jimmy said:
How can i format text, so that user input such as,
01062004 would be formatted as 01/06/2004. I've tried
several user-defined number and date formats, but I seem
to be missing something.

Use 'DateTime.Parse' to convert the text into a 'DateTime', then use its
'ToString' method with a custom format.
 
Jimmy said:
How can i format text, so that user input such as,
01062004 would be formatted as 01/06/2004. I've tried
several user-defined number and date formats, but I seem
to be missing something.

dim d as date
d = date.parseexact("01062004", "MMddyyyy", nothing)
msgbox d.tostring("MM/dd/yyyy")
 
Back
Top