|
-
Jun 12th, 2013, 04:31 AM
#1
Thread Starter
New Member
How to? chunk or split ?
Hello,
I have to work with this kind of string
dim my string = "20130612"
I would like to get 2013-06-12. (with a - as separator every 2 characters)
I can use mid(...) or substring(...), in my case
but I would like to know if there is a existing native function in vb for that.
In php, I use chunk_split(mystring, chunkLengh)
Isa
-
Jun 12th, 2013, 04:58 AM
#2
Re: How to? chunk or split ?
Hi,
You can convert any string that represents a true date time value using the ParseExact method of the DataTime Structure. i.e:_
Code:
Dim myDateFromString As DateTime = DateTime.ParseExact("20130612", "yyyyMMdd", CultureInfo.InvariantCulture)
MsgBox(myDateFromString.ToLongDateString)
You can then format this DateTime variable to display its information in which ever format you need. Have a look here for more information:-
http://msdn.microsoft.com/en-us/libr...code-snippet-1
Hope that helps.
Cheers,
Ian
-
Jun 12th, 2013, 07:23 AM
#3
Thread Starter
New Member
Re: How to? chunk or split ?
Many thanks fer reply, Ian,
I will try to use the ParseExact method
Isa
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|