Results 1 to 2 of 2

Thread: ASP Split Function

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    181

    Question

    Could someone please tell me what the VB equivalent of the ASP 'Split' function is?

    A VB function would work if that is more convinient

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'split function for VB5 and under   vb6 has the function
    'posted originally by Aaron Yount
    
    Public Function Split2(ByVal sString As String, ByVal sSeparator As String) As Variant
        Dim sParts() As String
        Dim lParts As Long
        Dim lPos As Long
        
        lPos = InStr(sString, sSeparator)
        While lPos
            ReDim Preserve sParts(lParts)
            sParts(lParts) = Left(sString, lPos - 1)
            sString = Mid(sString, lPos + Len(sSeparator))
            lPos = InStr(sString, sSeparator)
            lParts = lParts + 1
        Wend
        If Len(sString) Then
            ReDim Preserve sParts(lParts)
            sParts(lParts) = sString
        End If
        Split2 = IIf(lParts, sParts, Array())
    End Function
    
    'Example:
    
    Private Sub Form_Load()
        Dim vLines As Variant
        Dim lLine As Long
        
        vLines = Split2("Line1,Line2,Line3", ",")
        For lLine = 0 To UBound(vLines)
            List1.AddItem vLines(lLine)
        Next
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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