I'm using VB.NET 2003 version.
When reading a date from a file it is provided to VB as a string, right? So I have "dateShown" as the variable that the line from the file is stored too. How can I convert the data in the string into a date?
Printable View
I'm using VB.NET 2003 version.
When reading a date from a file it is provided to VB as a string, right? So I have "dateShown" as the variable that the line from the file is stored too. How can I convert the data in the string into a date?
The handy search function on this forum will pull several examples, dont forget that its there...
http://www.vbforums.com/search.php?q...0&saveprefs=1&
I've edited your thread title to include the version that you specified in your message body. This helps people that want to help you know what sort of coding advice to provide.
Please use the radio buttons provided to specify what version you are using when creating new threads in the future.
Thanks. :)
In all of the examples I find it has an exact date converted into an exact date of a different format. If I don't know the exact date, because I am reading it from a file, how can I still change it to the format I want it to be in?
Thanks
A string is a string is a string. You pass the string you read from the file to whatever method you are using. You can use Parse or ParseExact. If the string contains a date in one of the recognised standard formats then use Parse. If it contains a known, non-standard format then use ParseExact. If you have no idea what format it will be in then you have a problem. You can use Parse and catch any exception that might be thrown, then try ParseExact with some likely alternatives but generally speaking data to be read by computer programs should have some consistent structure to it.