Re: [VB5) Faster way to read a text file?
- From: "MikeD" <nobody@xxxxxxxxxxx>
- Date: Wed, 15 Aug 2007 22:34:51 -0400
"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:OgEyy753HHA.1900@xxxxxxxxxxxxxxxxxxxxxxx
Speaking of which, has anybody taken a look at the code example that goes
along with the Reset help? I can't ever imagine opening and/or closing
files that way.
Ya know, you COULD have posted the example so we all wouldn't need to go
look it up. <g>
Here it is:
-------
Reset Statement Example
This example uses the Reset statement to close all open files and write the
contents of all file buffers to disk. Note the use of the Variant variable
FileNumber as both a string and a number.
Dim FileNumber
For FileNumber = 1 To 5 ' Loop 5 times.
' Open file for output. FileNumber is concatenated into the string
' TEST for the file name, but is a number following a #.
Open "TEST" & FileNumber For Output As #FileNumber
Write #FileNumber, "Hello World" ' Write data to file.
Next FileNumber
Reset ' Close files and write contents
' to disk.
------
I see nothing wrong with the example in *specific* regard to how it's
opening/closing the files. Admittedly, I don't think I've EVER used Reset. I
always use Close. However, I *do* question the use of the Variant and that
the example even points out its use as an apparent "plus".
It'd be almost as bad as using Exit Do! <totally mooning all
non-structured-programming-maniacs out there...which is most of you> :)
I don't think that Exit Do (or Exit For) is necessarily a bad thing. As with
anything, sure, it can be abused/misused and you end up with sloppy code.
But use of it when appropriate, IMO, doesn't make code non-structured. If
the need for looping has ended, then why continue with the loop
unnecessarily? To me, it's GOOD programming to end the loop when whatever
need for the loop has been satisfied. I will say that I think it's better
for the loop condition itself to be met such that the loop ends "naturally",
but that's not always the case.
Let's just say that you need to loop through an array to find a unique value
assigned to an element. And let's also say this array has 1000 elements. And
let's also say the unique value you need to find is assigned to the first
element. Does it really make sense to loop another 999 times after you've
already found what you need? I don't think so.
--
Mike
Microsoft MVP Visual Basic
.
- Follow-Ups:
- Re: [VB5) Faster way to read a text file?
- From: Robert Morley
- Re: [VB5) Faster way to read a text file?
- References:
- [VB5) Faster way to read a text file?
- From: Gilles Ganault
- Re: [VB5) Faster way to read a text file?
- From: Schmidt
- Re: [VB5) Faster way to read a text file?
- From: Schmidt
- Re: [VB5) Faster way to read a text file?
- From: Randy Birch
- Re: [VB5) Faster way to read a text file?
- From: Robert Morley
- [VB5) Faster way to read a text file?
- Prev by Date: Re: How to make MSHFlexgrid display at last row
- Next by Date: Re: Visual Basic 6 OLEAUT32.DLL Security Update
- Previous by thread: Re: [VB5) Faster way to read a text file?
- Next by thread: Re: [VB5) Faster way to read a text file?
- Index(es):
Relevant Pages
|