Results 1 to 3 of 3

Thread: How to? chunk or split ?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    10

    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

  2. #2
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    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

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    10

    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
  •  



Click Here to Expand Forum to Full Width