all groups > vb.net controls > june 2007 >
You're in the

vb.net controls

group:

Open sequential file


Open sequential file Skenny
6/20/2007 7:25:43 AM
vb.net controls:
Hello, Im new to Visual basic 2005 express.
Been using VB6 for a couple of years.
What is the format for reading seq files line by line?
In VB6 it was: (very simplified)

open "file" for input as #1
Do until eof(1)
input #1, "string"
loop
close 1

But of course this doesnt work in vb express.
Re: Open sequential file Dick Grier
6/20/2007 10:26:33 AM
Hi,

You can use FileOpen. This syntax is similar to what you are familiar with:

FileOpen(Filenum, FileName, OpenMode.Input) 'etc.

Or, you can use a StreamReader (more ".NET" syntax). So, this may be the
way that you want to go:

http://msdn2.microsoft.com/en-us/library/yw67h925(VS.80).aspx

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.

Re: Open sequential file Skenny
6/20/2007 2:11:50 PM
[quoted text, click to view]
Ok thanks!! This helps a lot.
I played around with it a bit and figured out that FileClose(Filenum)is
the proper way to close the file.
Can you use FileSave to save a file?
Re: Open sequential file Dick Grier
6/21/2007 10:02:04 AM
Hi,

I don't know what FileSave might be. You can use FilePut (or VB syntax
Write or Print) to save variables to an open file. You can use a
BinaryWriter or TextWriter to save data to a file Stream. You can use
FileCopy to copy an entire file.

And, you can use My.Computer.FileSystem for a wide variety of productivity
methods for dealing with files. Take look in Help.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.

AddThis Social Bookmark Button