Hi @NasaCow
As you know, we can't do arrays in arrays, so there is no simple solution you are missing.
You can store an array into a string using a Join$ function, just give it an array and a delimiter to separate the different values.
It's brother is a Split Sub that takes the string and breaks it back up into an array: you give it a dynamic array name to load and tell it what the string is that contains the array and the delimiter used.
Here are the Join$ and Split routines I use:
I will be surprised if you get this in one go and if your array is an UDT (User Desigined Type) it's more complicated still.
I am wondering if I went over something like this when you were last here. The Join$ and Split Routines work very well as I have done GUI and Interpreter with them!
A further complication is if you want to file all this, and why not! Then you have to use fixed strings or some fancy Binary file header.
As you know, we can't do arrays in arrays, so there is no simple solution you are missing.
You can store an array into a string using a Join$ function, just give it an array and a delimiter to separate the different values.
It's brother is a Split Sub that takes the string and breaks it back up into an array: you give it a dynamic array name to load and tell it what the string is that contains the array and the delimiter used.
Here are the Join$ and Split routines I use:
Code: (Select All)
' note: I buggered this twice now, FOR base 1 array REDIM MyArray (1 to 1) AS ... the (1 to 1) is not same as (1) which was the Blunder!!!
'notes: REDIM the array(0) to be loaded before calling Split '<<<< IMPORTANT dynamic array and empty, can use any lbound though
'This SUB will take a given N delimited string, and delimiter$ and create an array of N+1 strings using the LBOUND of the given dynamic array to load.
'notes: the loadMeArray() needs to be dynamic string array and will not change the LBOUND of the array it is given. rev 2019-08-27
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
I will be surprised if you get this in one go and if your array is an UDT (User Desigined Type) it's more complicated still.
I am wondering if I went over something like this when you were last here. The Join$ and Split Routines work very well as I have done GUI and Interpreter with them!
A further complication is if you want to file all this, and why not! Then you have to use fixed strings or some fancy Binary file header.
b = b + ...