Hello,
I need to be able to split a string into multi-dimensional array.
At first, I opened a file delimited by semicolon.
and I just want to read first 4 lines of the file to grab the data I need.
Here is an attempt which failed:
so, my array would look something like
at the end of the day, if the file looks like this:
a;b;c;d;e;f
a;b;c;d;e;f
a;b;c;d;e;f
a;b;c;d;e;f
Thank you in advance,
Kpark.
Any suggestions are welcome!
PS: If anybody is wondering why I might be using a 2-dimensional array is because I need to make sure the file is valid.
That means the file must consist of at least 4 lines but I had no way of checking it without reading the whole file first then looping to find the number of vbNewLine.
So, in this, I'm trying to store the data while I am reading each line of the file which should give better runtime.
I need to be able to split a string into multi-dimensional array.
At first, I opened a file delimited by semicolon.
and I just want to read first 4 lines of the file to grab the data I need.
Here is an attempt which failed:
Code:
Sub Test()
Dim objFSO As New FileSystemObject, objFile As Object, i&, strDataSetting$(0 To 3, 0 To 5)
If objFSO.FileExists(strPath) Then
With objFSO.OpenTextFile(strPath, ForReading)
For i = 0 To 3
If Not .AtEndOfStream Then
strDataSetting(i,) = Split(.ReadLine, ";")
End If
Next i
End With
End If
End Sub
so, my array would look something like
Code:
strDataSetting
i\j 0 1 2 3 4 5
0 a b c d e f
1 a b c d e f
2 a b c d e f
3 a b c d e f
at the end of the day, if the file looks like this:
a;b;c;d;e;f
a;b;c;d;e;f
a;b;c;d;e;f
a;b;c;d;e;f
Thank you in advance,
Kpark.
Any suggestions are welcome!
PS: If anybody is wondering why I might be using a 2-dimensional array is because I need to make sure the file is valid.
That means the file must consist of at least 4 lines but I had no way of checking it without reading the whole file first then looping to find the number of vbNewLine.
So, in this, I'm trying to store the data while I am reading each line of the file which should give better runtime.
Last edited: