Connecting Tech Pros Worldwide Forums | Help | Site Map

Opening sequential files

Geoff
Guest
 
Posts: n/a
#1: Jan 17 '07
I have a sequential text file, Clients.txt, and when my form loads I would
like the first record only to be displayed - that's if it exists! Initially
Clients.txt is blank. Well I 'm getting error messages when the below code
is triggered for an empty file.



Private Sub Form_Load()

Dim Firstrec As Boolean



Firstrec = False



FileName = App.Path & "\Clients.txt"

Open FileName For Input As #1



Do While Not (EOF(1) Or (Firstrec = True))

Call ReadCLientRec

Call DisplayClientRec

Firstrec = True

Loop



Close #1

End Sub



What's up with this VB6 code and is there an easier approach? Any help
would be appreciated

Thanks

Geoff



Rick Rothstein \(MVP - VB\)
Guest
 
Posts: n/a
#2: Jan 18 '07

re: Opening sequential files


>I have a sequential text file, Clients.txt, and when my form loads I would
Quote:
>like the first record only to be displayed - that's if it exists!
>Initially Clients.txt is blank. Well I 'm getting error messages when the
>below code is triggered for an empty file.
An "empty" file (one that exists but has no text in it) or file that isn't
there at all? Oh, and so we don't have to guess, what is the error message
you are getting and on what line is it occurring? Finally, since I'm
guessing the ReadCLientRec is doing the bulk of the work, you might want to
show us its code also.

Rick


Closed Thread