Split Function/text/sbasic/shared/03120314.xhpSplit function
Split Function
Returns an array of substrings from a string expression.Split (expression As String, delimiter, limit)With Option VBASupport 1: String, with Option VBASupport 0: Variant/Stringexpression: Any string expression.delimiter: An optional string of one or more characters length that is used to delimit String. The default is the space character.limit: An optional number of substrings that you want to return.Dim a(3)Sub main() a(0) = "ABCDE" a(1) = 42 a(2) = "MN" a(3) = "X Y Z" JStr = Join1() Call Show(JStr, Split1(JStr)) JStr = Join2() Call Show(JStr, Split1(JStr)) JStr = Join3() Call Show(JStr, Split1(JStr))End SubFunction Join1() Join1 = Join(a(), "abc")End FunctionFunction Join2() Join2 = Join(a(), ",")End FunctionFunction Join3() Join3 = Join(a())End FunctionFunction Split1(aStr) Split1 = Split(aStr, "D")End FunctionSub Show(JoinStr, TheArray) l = LBound(TheArray) u = UBound(TheArray) total$ = "=============================" + Chr$(13) + JoinStr + Chr$(13) + Chr$(13) For i = l To u total$ = total$ + TheArray(i) + Str(Len(TheArray(i))) + Chr$(13) Next i MsgBox total$End Sub