473,503 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to rewind a file

Assume that the first line of a file is read with:

InputLine = LineInput(FileNum)
I believe a file can be rewound as follows:
(So that the first line can be reread)
FileClose(FileNum) 'Rewind

FileOpen(FileNum, mDataInFullPath, OpenMode.Input)

InputLine = LineInput(FileNum)

Isn't there a better way?



Thanks
Dec 13 '05 #1
4 7687
" **Developer**" <RE*************@a-znet.com> wrote in message
news:OE**************@TK2MSFTNGP14.phx.gbl...
Assume that the first line of a file is read with:

InputLine = LineInput(FileNum)


Looks like the Seek method is still supported so..... no need to close, just
use Seek.

Seek(FileNum, 1)

I'd provide the sample code the VB6 migration wizard provided but.... VSNet
crashed and burned when I hit F1 (or, maybe 90 seconds isn't enough to open
help anymore <sigh>) to look up help on the Seek method so.....

fwiw, I've written VB6 apps that use Seek to mark (and store) the beginning
of each line as they're read so I can return to any line in the file at
will. Surely, there's similar support in .Net (if you can keep it running
anyway ;-)

--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..
Dec 13 '05 #2
I wasn't sure if Seek worked with LineInput.

Thanks
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message
news:ui**************@TK2MSFTNGP14.phx.gbl...
" **Developer**" <RE*************@a-znet.com> wrote in message
news:OE**************@TK2MSFTNGP14.phx.gbl...
Assume that the first line of a file is read with:

InputLine = LineInput(FileNum)


Looks like the Seek method is still supported so..... no need to close,
just use Seek.

Seek(FileNum, 1)

I'd provide the sample code the VB6 migration wizard provided but....
VSNet crashed and burned when I hit F1 (or, maybe 90 seconds isn't enough
to open help anymore <sigh>) to look up help on the Seek method so.....

fwiw, I've written VB6 apps that use Seek to mark (and store) the
beginning of each line as they're read so I can return to any line in the
file at will. Surely, there's similar support in .Net (if you can keep it
running anyway ;-)

--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..

Dec 13 '05 #3
Ken Halter wrote:
" **Developer**" <RE*************@a-znet.com> wrote in message
news:OE**************@TK2MSFTNGP14.phx.gbl...

Assume that the first line of a file is read with:

InputLine = LineInput(FileNum)


Looks like the Seek method is still supported so..... no need to close, just
use Seek.

Seek(FileNum, 1)

I'd provide the sample code the VB6 migration wizard provided but.... VSNet
crashed and burned when I hit F1 (or, maybe 90 seconds isn't enough to open
help anymore <sigh>) to look up help on the Seek method so.....

fwiw, I've written VB6 apps that use Seek to mark (and store) the beginning
of each line as they're read so I can return to any line in the file at
will. Surely, there's similar support in .Net (if you can keep it running
anyway ;-)

Yes, seek(FileNum,1) is the way, and seek(FileNum) still returns the
current position. This is regardless of the method used to read the file.

Tom
Dec 14 '05 #4
thanks.

I noticed you send HTML. I was under the impression that many do not like
to receive HTML.

I like HTML but avoid it because it may be inconvenient for some.

Is that an obsolete notion?

"tomb" <to**@technetcenter.com> wrote in message
news:sc******************@bignews1.bellsouth.net.. .
Ken Halter wrote:

" **Developer**" <RE*************@a-znet.com> wrote in message
news:OE**************@TK2MSFTNGP14.phx.gbl...

Assume that the first line of a file is read with:

InputLine = LineInput(FileNum)

Looks like the Seek method is still supported so..... no need to close, just
use Seek.

Seek(FileNum, 1)

I'd provide the sample code the VB6 migration wizard provided but.... VSNet
crashed and burned when I hit F1 (or, maybe 90 seconds isn't enough to open
help anymore <sigh>) to look up help on the Seek method so.....

fwiw, I've written VB6 apps that use Seek to mark (and store) the beginning
of each line as they're read so I can return to any line in the file at
will. Surely, there's similar support in .Net (if you can keep it running
anyway ;-)
Yes, seek(FileNum,1) is the way, and seek(FileNum) still returns the current
position. This is regardless of the method used to read the file.

Tom
Dec 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9806
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
3
8448
by: Don Pasquale | last post by:
The following function intends to delete "numberoflines" lines from a text file, named "s" (string pointer) and pointed to by file pointer "fp", starting from line "line". Now, the function...
2
1855
by: yezi | last post by:
Hi, ALl: The following code is to canculate 2 vector distance. Suppose the vectore is stored in some txt file like -1 0.34 0 0.045 1 0.98 1 0.01
5
1610
by: poison.summer | last post by:
Hello I need to write and read a parameter through a file to get communication between two processes. I know how to use fopen, fprintf. But I wonder how can I overwrite the old files. For...
0
1083
by: Charles D Hixson | last post by:
I was reading through old messages in the list and came up against an idea that I thought might be of some value: "Wouldn't it be a good idea if one could "rewind" an iterator?" Not stated in...
24
3378
by: Olaf \El Blanco\ | last post by:
Where is exactly neccesary to put "rewind(stdin)"? After a printf? Before a scanf? I have a lot of problems with strings... If somebody know any good document, please let me know where is... ...
32
5820
by: Olivier | last post by:
Dear all, I thought the code ----------------------------- pt_fichier_probleme = fopen(nom_fichier, "w"); if(pt_fichier_probleme == NULL){ message_warning_s ("Erreur l'ouverture du...
9
5587
by: Morris Neuman | last post by:
Im working with VS 2005 and trying to use a Hyperlink field in a datagrid to play a wave file that is not located in the website folders but is in a plain folder on the same machine, windows 2003...
5
3525
by: gp | last post by:
i am implementing Iterator in a class, I have pretty much copied the code from php.net on Object Iteration. Adding all the normal methods for the task...rewind, current, next, etc. I was...
24
4413
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7348
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7006
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5592
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3166
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.