Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
Opening sequential files
Old
  (#1)
Geoff
Guest
 
Posts: n/a
Default Opening sequential files - 06-04-2007, 10:35 AM

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


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Opening sequential files
Old
  (#2)
Rick Rothstein \(MVP - VB\)
Guest
 
Posts: n/a
Default Re: Opening sequential files - 06-04-2007, 10:35 AM

>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.


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


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top