Results 1 to 4 of 4

Thread: Split (for VB before 6)

  1. #1

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Split (for VB before 6)

    Since the Split function was added in VB6, whoever has a previous version of VB can use this

    VB Code:
    1. Private Function Split2(ByVal sString As String, ByVal sSeparator As String) As Variant
    2.     Dim sParts() As String
    3.     Dim lParts As Long
    4.     Dim lPos As Long
    5.         lPos = InStr(sString, sSeparator)
    6.     While lPos
    7.         ReDim Preserve sParts(lParts)
    8.         sParts(lParts) = Left(sString, lPos - 1)
    9.         sString = Mid(sString, lPos + Len(sSeparator))
    10.         lPos = InStr(sString, sSeparator)
    11.         lParts = lParts + 1
    12.     Wend
    13.     If Len(sString) Then
    14.         ReDim Preserve sParts(lParts)
    15.         sParts(lParts) = sString
    16.         lParts = lParts + 1
    17.     End If
    18.     Split2 = IIf(lParts, sParts, Array())
    19. End Function


    Has someone helped you? Then you can Rate their helpful post.

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Split (for VB before 6)

    Great nice code.

    Very useful for compatability too, I tried writing something like this for LB once and I failed dismally I may add

    Cheers,

    RyaNj
    My Blog.

    Ryan Jones.

  3. #3

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Split (for VB before 6)

    Thanks, but I can't take credit for it... I had found it somewhere else on the forum and I dug it up now


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Split (for VB before 6)

    Quote Originally Posted by manavo11
    Thanks, but I can't take credit for it... I had found it somewhere else on the forum and I dug it up now

    Still not the point, I'm going to see if that is compatible with LB and then there would finally be a split function that works

    Cheers,

    RyaNJ
    My Blog.

    Ryan Jones.

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