Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake a function to split a string into an array of strings by using multiple separators in Visual Basic 6.
DescriptionThis example shows how to make a function to split a string into an array of strings by using multiple separators in Visual Basic 6.
Keywordssplit, string, separators
CategoriesStrings
 
Thanks to Mariusz S.

Function SplitEx finds the first separator in its parameter array. It then loops through the other separators, replacing them with the first one. Finally it uses Split to split the string into an array using just the first separator.

 
Function SplitEx(ByVal s As String, ParamArray separators() _
    As Variant) As String()
Dim sep As String
Dim i As Integer

    sep = separators(LBound(separators))

    'function logic: replaces different separators with one
    ' set at t(lbound(t))
    For i = LBound(separators) + 1 To UBound(separators)
        s = Replace(s, separators(i), sep)
    Next i

    'finally internally calls default VB Split function
    SplitEx = Split(s, sep)
End Function
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated