How can I determine the total number of lines in a text
file that contains streams of text data, without going
into a loop that reads the lines one by one?
Also, I use the following code to read each line and
proceed to the next one:
'****************************************
Dim sr as StreamReader = New StreamReader("C:\MyFile.TXT")
Dim line as String = sr.ReadLine()
'****************************************
How do I point the reference to line number 75 in the
text file for example without reading the lines one by
one in a loop? And how do I read the last line in the
text file directly?
Thanks
Amjad 9 1564
"Amjad" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl... How can I determine the total number of lines in a text file that contains streams of text data, without going into a loop that reads the lines one by one?
Also, I use the following code to read each line and proceed to the next one: '**************************************** Dim sr as StreamReader = New StreamReader("C:\MyFile.TXT") Dim line as String = sr.ReadLine() '**************************************** How do I point the reference to line number 75 in the text file for example without reading the lines one by one in a loop? And how do I read the last line in the text file directly?
Thanks Amjad
ReadAll method.
Split to an array using vbNewLine or vbCrLf as the delimiter.
ArrayName.GetUpperBound(0) + 1 = Number of Lines In File
Mythran
Hi Amjad,
Can you drink the bottom of your glas first?
Cor
"Cor" <no*@non.com> wrote in message
news:uo*************@TK2MSFTNGP11.phx.gbl... Hi Amjad,
Can you drink the bottom of your glas first?
Cor
If your using a straw you can... Sorry I couldn't resist
* "Amjad" <an*******@discussions.microsoft.com> scripsit: How can I determine the total number of lines in a text file that contains streams of text data, without going into a loop that reads the lines one by one?
Also, I use the following code to read each line and proceed to the next one: '**************************************** Dim sr as StreamReader = New StreamReader("C:\MyFile.TXT") Dim line as String = sr.ReadLine() '**************************************** How do I point the reference to line number 75 in the text file for example without reading the lines one by one in a loop? And how do I read the last line in the text file directly?
There is no better way because there is nowhere stored where line number
n starts. You may want to maintain a separate index file, but notice
that all start indices of succeeding lines will change when inserting a
longer/shorter line.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Hi Cor,
Yes I can, if I pointed to the bottom of the glass and
made a little hole there!
Amjad -----Original Message----- Hi Amjad,
Can you drink the bottom of your glas first?
Cor
.
LOL
You are right there was something wrong with this text If your using a straw you can... Sorry I couldn't resist
Hi Amjad, Yes I can, if I pointed to the bottom of the glass and made a little hole there!
Can you drink the bottom of your glas first?
That was an answer I did wanted to reply,
Because I did wanted to answer is it worth that much work for such a simple
thing
Cor
surely this is a function of the glass object?? I presume you need to
implement a drinkfrombottom() method?
Regards
Simon
"Cor" <no*@non.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl... Hi Amjad,
Yes I can, if I pointed to the bottom of the glass and made a little hole there!
Can you drink the bottom of your glas first? That was an answer I did wanted to reply,
Because I did wanted to answer is it worth that much work for such a
simple thing
Cor
Alright now I think we all need to go home and have a drink, but remember
drink it from the bottom of the glass and give a detailed explination of how
you did it after the holiday.. :)
Merry Christmas..
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... surely this is a function of the glass object?? I presume you need to implement a drinkfrombottom() method?
Regards Simon "Cor" <no*@non.com> wrote in message news:OM**************@TK2MSFTNGP11.phx.gbl... Hi Amjad,
Yes I can, if I pointed to the bottom of the glass and made a little hole there!
>Can you drink the bottom of your glas first? >
That was an answer I did wanted to reply,
Because I did wanted to answer is it worth that much work for such a simple thing
Cor
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: BadOmen |
last post by:
I have a text file that I want to save from my program. But I don't want to
save the empty lines. I want to delete everything after the last character,
Is that possible?
Then when I read the...
|
by: Jesse Noller |
last post by:
I am a relative newbie to python and I am having issues trying to
iterate over the lines of a file.
I have a text file - foo.bar inside of this file are lines of text:
x-3411342
y-1324123...
|
by: Ruben |
last post by:
Hello.
I am trying to read a small text file using the readline statement. I
can only read the first 2 records from the file. It stops at the blank
lines or at lines with only spaces. I have a...
|
by: Ling Lee |
last post by:
Hi all.
I'm trying to write a program that:
1) Ask me what file I want to count number of lines in, and then counts the
lines and writes the answear out.
2) I made the first part like this:
...
|
by: MJ |
last post by:
Currently i am using the below coding to create a text file and write something on it.
Dim wfile As New System.IO.StreamWriter("c:\test.txt"
wfile.WriteLine("Hello" & vbcrlf & "Are" & vbcrlf &...
|
by: Vasilis Serghi |
last post by:
Presently I define the number of lines to be expected in a file when
defining the array size and the initialisation of this array. This works
fine for now, but i'm sure that in the future this...
|
by: TheGanjaMan |
last post by:
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...
|
by: ivan.perak |
last post by:
Hello,
im a beginner in VB.NET... The thing i would like to do is as it
follows....
I have a text file (list of names, every name to the next line) which
is about 350000 lines long. I would...
|
by: peraklo |
last post by:
Hello,
there is another problem i am facing. i have a text file which is
about 15000 lines big. i have to cut the last 27 lines from that file
and create a new text file that contans those 27...
|
by: Barkingmadscot |
last post by:
I am stuck, i can workout how to remove lines from an array
I have loading a text file (a Log), I know which lines a need, but
the logs can be upto 30K sometimes bigger. I found trying to...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |