For an array of variable length strings:
Join$ will turn a String Array into a LongString$ and Split will pop an array out of a LongString$
Used successfully in UDT's for my Interpreter and my GUI among other things like avoiding Data and Read statements.
So an extra step or two but oh the power!
Join$ will turn a String Array into a LongString$ and Split will pop an array out of a LongString$
Code: (Select All)
Sub Split (SplitMeString As String, delim As String, loadMeArray() As String)
Dim curpos As Long, arrpos As Long, LD As Long, dpos As Long 'fix use the Lbound the array already has
curpos = 1: arrpos = LBound(loadMeArray): LD = Len(delim)
dpos = InStr(curpos, SplitMeString, delim)
Do Until dpos = 0
loadMeArray(arrpos) = Mid$(SplitMeString, curpos, dpos - curpos)
arrpos = arrpos + 1
If arrpos > UBound(loadMeArray) Then ReDim _Preserve loadMeArray(LBound(loadMeArray) To UBound(loadMeArray) + 1000) As String
curpos = dpos + LD
dpos = InStr(curpos, SplitMeString, delim)
Loop
loadMeArray(arrpos) = Mid$(SplitMeString, curpos)
ReDim _Preserve loadMeArray(LBound(loadMeArray) To arrpos) As String 'get the ubound correct
End Sub
Function Join$ (arr() As String, delimiter$)
Dim i As Long, b$
For i = LBound(arr) To UBound(arr)
If i = LBound(arr) Then b$ = arr(LBound(arr)) Else b$ = b$ + delimiter$ + arr(i)
Next
Join$ = b$
End Function
Used successfully in UDT's for my Interpreter and my GUI among other things like avoiding Data and Read statements.
So an extra step or two but oh the power!
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever

