Reading In a Space delimited File
I was wondering what the best way to read in a space delimited file would be? I would love to just do a ReadLine() followed by a String.Split(" ") but the problem is that there is a variable amount of spaces between the values, not just one. Is there a way to make String.Split() treat consecutive delimiters as one? If not, what is the best way to read in a line of values and split them up? I have code that does this by reading one character at a time, checking if it is a space or tab and then reading and discarding until another non-space, non-tab character is found. It's pretty tedious though and I was wondering if there was an easier method.
- Tom
Re: Reading In a Space delimited File
TSmooth,
you can replace two spaces at a time in a loop before using split
Code:
While s.IndexOf(" ") >= 0
s = s.Replace(" ", " ")
MsgBox(s) ' just to see the progress
End While
Hope it helps
Re: Reading In a Space delimited File
You could also do the usual Split() with space/tab and then discard the undesirable entries by looping through the resulting array.