T
TheGanjaMan
Hi people,
I'm stuck on a problem and I was wondering if there was a way around:
I'm trying to find the number of lines in a comma delimited text file.
I have a progress bar that should display the progress of a text file that
is being read into a DataGridView. I would like the progressbar to
progress as the lines of data are being read.
But to set the maximum value for the progress bar I would need to know the
maximum line number of the text file.
I've used the following code to open the file, and
Dim myReader As New Microsoft.VisualBasic.FileIO.TextFieldParser
("text.csv", System.Text.Encoding.Default)
myReader.TextFieldType = FileIO.FieldType.Delimited
myReader.SetDelimiters(";")
I can read the contents of the file with a do loop, but is there a way to
get the number of lines in the file without a do loop statement? if not
I'd have to do a do loop to count the lines and set the number of lines to
the progressbar.maximum, and then do loop again to read the file with the
progressbar.value set to the current line in the loop.
Any ideas...
Thanks.
I'm stuck on a problem and I was wondering if there was a way around:
I'm trying to find the number of lines in a comma delimited text file.
I have a progress bar that should display the progress of a text file that
is being read into a DataGridView. I would like the progressbar to
progress as the lines of data are being read.
But to set the maximum value for the progress bar I would need to know the
maximum line number of the text file.
I've used the following code to open the file, and
Dim myReader As New Microsoft.VisualBasic.FileIO.TextFieldParser
("text.csv", System.Text.Encoding.Default)
myReader.TextFieldType = FileIO.FieldType.Delimited
myReader.SetDelimiters(";")
I can read the contents of the file with a do loop, but is there a way to
get the number of lines in the file without a do loop statement? if not
I'd have to do a do loop to count the lines and set the number of lines to
the progressbar.maximum, and then do loop again to read the file with the
progressbar.value set to the current line in the loop.
Any ideas...
Thanks.