Connecting Tech Pros Worldwide Help | Site Map

Opening sequential files

  #1  
Old January 17th, 2007, 11:05 PM
Geoff
Guest
 
Posts: n/a
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


  #2  
Old January 18th, 2007, 12:15 AM
Rick Rothstein \(MVP - VB\)
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Lines in (Huge) Text Files NvrBst answers 9 August 16th, 2008 06:45 AM
text and binary files confusion joelagnel@gmail.com answers 10 March 17th, 2006 12:15 PM
Playing a sound Lee Moody answers 7 November 20th, 2005 05:03 AM
Simple question regarding opening/finding/saving data in text files. Ponder answers 3 July 17th, 2005 09:30 PM