"Array1(1 to 25), Array2(1 to 85), Array3(1 to 15) etc. I have tried this before and there is no way QB64PE can create array names on the fly using concatenation."
You can do this without special array names or even multiple arrays.
I have lectured on this many times here that variable length strings can be made to function like arrays AND that to have sequence of variables ie var1, var2, var3, ...
Just use an array of variable length strings so
array$(1) = "1, 2, 3, 4, 5"
array$(2) = "1, 4, 9, 16, 25, 36"
array$(3) = "2, 4, 6"
array$(4) = "1, 1, 2, 4, 3, 9, 4, 16, 5, 25, 6, 36"
array$(5) = "a, b, c"
array$(6) = "dim, ster"
array$(7) = "b, p, l, us"
This extracts the item number from such a string:
The delimiter$ of the sample strings I gave is ", "
So all the 2nd items in all those strings that function like arrays are:
You can do this without special array names or even multiple arrays.
I have lectured on this many times here that variable length strings can be made to function like arrays AND that to have sequence of variables ie var1, var2, var3, ...
Just use an array of variable length strings so
array$(1) = "1, 2, 3, 4, 5"
array$(2) = "1, 4, 9, 16, 25, 36"
array$(3) = "2, 4, 6"
array$(4) = "1, 1, 2, 4, 3, 9, 4, 16, 5, 25, 6, 36"
array$(5) = "a, b, c"
array$(6) = "dim, ster"
array$(7) = "b, p, l, us"
This extracts the item number from such a string:
Code: (Select All)
Function Item$ (s$, nItem As Long, delimiter$)
Dim c As Long, d As Long, lastd As Long
If Len(s$) = 0 Then Item$ = "": Exit Function
lastd = 1: d = InStr(lastd, s$, delimiter$)
While d > 0
c = c + 1
If c = nItem Then
Item$ = Mid$(s$, lastd, d - lastd): Exit Function
Else
lastd = d + 1: d = InStr(lastd, s$, delimiter$)
End If
Wend
c = c + 1
If c <> nItem Then Item$ = "" Else Item$ = Mid$(s$, lastd, Len(s$))
End Function
The delimiter$ of the sample strings I gave is ", "
So all the 2nd items in all those strings that function like arrays are:
Code: (Select All)
array$(1) = "1, 2, 3, 4, 5"
array$(2) = "1, 4, 9, 16, 25, 36"
array$(3) = "2, 4, 6"
array$(4) = "1, 1, 2, 4, 3, 9, 4, 16, 5, 25, 6, 36"
array$(5) = "a, b, c"
array$(6) = "dim, ster"
array$(7) = "b, p, l, us"
For i = 1 To 7
Print Item$(array$(i), 2, ", ")
Next
Function Item$ (s$, nItem As Long, delimiter$)
Dim c As Long, d As Long, lastd As Long
If Len(s$) = 0 Then Item$ = "": Exit Function
lastd = 1: d = InStr(lastd, s$, delimiter$)
While d > 0
c = c + 1
If c = nItem Then
Item$ = Mid$(s$, lastd, d - lastd): Exit Function
Else
lastd = d + 1: d = InStr(lastd, s$, delimiter$)
End If
Wend
c = c + 1
If c <> nItem Then Item$ = "" Else Item$ = Mid$(s$, lastd, Len(s$))
End Function
b = b + ...