Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #586
| From | "Auric__" <not.my.real@email.address> |
|---|---|
| Newsgroups | comp.lang.basic.visual.misc |
| Subject | Re: EOF Marker |
| Date | 2012-01-03 15:05 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <Xns9FCF51C75B44Bauricauricauricauric@88.198.244.100> (permalink) |
| References | <VVDMq.171568$6J7.5729@newsfe08.ams2> |
"Ivar" <ivar.ekstromer000@ntlworld.com> wrote:
> Got a bit of code that reads a text file, looks something like this:
>
> Open FilePath For Input As #FileNum
> Do Until EOF(FileNum)
> Line Input #FileNum, LineStr
> DoSomething
> Loop
> Close #FileNum
>
> Everything has been working well for a very long time until!
> The loop will exit long before it gets to the EOF
> I looked in the file using note pad, and there are some strange
> characters in some of the text lines. not the normal readable stuff that
> is expected How they got there is still a mystery.
> The question is - is there a chr in a text file that will cause the Do
> Loop to exit before the EOF
> Each of the lines that cause the loop to exit contain 'ลน' or '' Could
> this be the cause?
Do *all* lines with those chars exit?
> What to do if it happens again?
Open that file For Binary and parse it manually:
Open FilePath For Binary As #FileNum
LineStr = Space(LOF(FileNum))
Get #FileNum, 1, tmpstr
Close #FileNum
Dim FilePathArr As Variant
FilePathArr = Split(tmpstr, vbCrLf)
For L0 = 0 To UBound(FilePathArr)
LineStr = FilePathArr(L0)
DoSomething
Next L0
Binary doesn't care about special characters. (As an added bonus, this method
is usually faster than Line Input.)
--
STICK \'stik\ n. 1: A boomerang than doesn't work.
Back to comp.lang.basic.visual.misc | Previous | Next — Previous in thread | Next in thread | Find similar
EOF Marker "Ivar" <ivar.ekstromer000@ntlworld.com> - 2012-01-03 14:04 +0000
Re: EOF Marker "Auric__" <not.my.real@email.address> - 2012-01-03 15:05 +0000
Re: EOF Marker "Ivar" <ivar.ekstromer000@ntlworld.com> - 2012-01-03 16:05 +0000
Re: EOF Marker GS <gs@somewhere.net> - 2012-01-03 13:04 -0500
Re: EOF Marker "Theo Tress" <rbk@online.de> - 2012-01-20 17:45 +0100
csiph-web