CRLF
= Chr$(13) + Chr$(10) ' delimiter for txt files
ReDim txt$
(1 To 100) ' make an array of txt txt$
(i
) = "This is line" + Str$(i
)SaveArr2File txt$(), "Test 100 strings.txt" 'save to file
ReDim test$
(1 To 1) ' create array to store file contents into fCnt = LoadFile2ArrCnt&("Test 100 strings.txt", test$()) 'load file
For i
= 1 To fCnt
'show loaded file notice, it is 100 lines Do 'access line records randomly Input "Enter line / record to check (0 quits)"; lNum
Sub SaveArr2File
(Arr
() As String, FileName$
) 'assuming base 1 file loaded with code below If i
= 1 Then b$
= Arr
(1) Else b$
= b$
+ CRLF
+ Arr
(i
)
Split b$, CRLF, Arr()
LoadFile2ArrCnt&
= UBound(arr
)
' 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
curpos
= 1: arrpos
= LBound(loadMeArray
): LD
= Len(Delim
) dpos
= InStr(curpos
, SplitMeString
, Delim
) LoadMeArray
(arrpos
) = Mid$(SplitMeString
, curpos
, dpos
- curpos
) arrpos = arrpos + 1
curpos = dpos + LD
dpos
= InStr(curpos
, SplitMeString
, Delim
) LoadMeArray
(arrpos
) = Mid$(SplitMeString
, curpos
)