Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Opening sequential files

Question posted by: Geoff (Guest) on January 17th, 2007 10:05 PM
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


Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Rick Rothstein \(MVP - VB\)'s Avatar
Rick Rothstein \(MVP - VB\)
Guest
n/a Posts
January 17th, 2007
11:15 PM
#2

Re: Opening sequential files
>I have a sequential text file, Clients.txt, and when my form loads I would
Quote:
Originally Posted by
>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



 
Not the answer you were looking for? Post your question . . .
182,493 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors