Reading first record of txt file?? 
Author Message
 Reading first record of txt file??

How do a tell VB to get the first record in a text file that I opened for
input.
A EOF loop executed so the file is still at the last record, how can I tell
VB to go to the first record of that file?

Sorry if this sounds like a stupid question but I am still new to
programming

Regards
Jackie



Fri, 29 Mar 2002 03:00:00 GMT  
 Reading first record of txt file??
Hi,

What is the format of the file? Is it comma delimited? Send a few lines of
the text file so that you get accurate help.

Regards,
    Tony


Quote:
>How do a tell VB to get the first record in a text file that I opened for
>input.
>A EOF loop executed so the file is still at the last record, how can I tell
>VB to go to the first record of that file?

<SNIP>


Fri, 29 Mar 2002 03:00:00 GMT  
 Reading first record of txt file??
You have opened the file giving it a 'filenumber'.  Use that number in:

Seek #<filenumber>, 1

LFS


Quote:

> How do a tell VB to get the first record in a text file that I opened for
> input.
> A EOF loop executed so the file is still at the last record, how can I tell
> VB to go to the first record of that file?

> Sorry if this sounds like a stupid question but I am still new to
> programming

> Regards
> Jackie



Fri, 29 Mar 2002 03:00:00 GMT  
 Reading first record of txt file??
On a sequential file ?  Seek requires a Binary open, right?

--

Randy Birch, MVP Visual Basic

http://www.mvps.org/vbnet/
http://www.mvps.org/ccrp/


| You have opened the file giving it a 'filenumber'.  Use that number in:
|
| Seek #<filenumber>, 1
|
| LFS
|

| >
| > How do a tell VB to get the first record in a text file that I opened
for
| > input.
| > A EOF loop executed so the file is still at the last record, how can I
tell
| > VB to go to the first record of that file?
| >
| > Sorry if this sounds like a stupid question but I am still new to
| > programming
| >
| > Regards
| > Jackie



Fri, 29 Mar 2002 03:00:00 GMT  
 Reading first record of txt file??
If you open a file for sequential input, as it sounds you have, then read
past a line you later want to re-read, you'll need to close and reopen the
file, start at the beginning again, and reread the file until you get to the
line of interest.

--

Randy Birch, MVP Visual Basic

http://www.mvps.org/vbnet/
http://www.mvps.org/ccrp/



| How do a tell VB to get the first record in a text file that I opened for
| input.
| A EOF loop executed so the file is still at the last record, how can I
tell
| VB to go to the first record of that file?
|
| Sorry if this sounds like a stupid question but I am still new to
| programming
|
| Regards
| Jackie
|
|



Fri, 29 Mar 2002 03:00:00 GMT  
 Reading first record of txt file??
Not so:

    Open "c:\autoexec.bat" For Input As 1
    Text1 = Input(LOF(1), 1)
    Seek 1, 1
    Text2 = Input(LOF(1), 1)
    Close

Perfectly legal.

LFS

Quote:

> On a sequential file ?  Seek requires a Binary open, right?

> --

> Randy Birch, MVP Visual Basic

> http://www.mvps.org/vbnet/
> http://www.mvps.org/ccrp/



> | You have opened the file giving it a 'filenumber'.  Use that number in:
> |
> | Seek #<filenumber>, 1
> |
> | LFS



Fri, 29 Mar 2002 03:00:00 GMT  
 Reading first record of txt file??
great.  never use sequential anymore, so good info to know.

--

Randy Birch, MVP Visual Basic

http://www.mvps.org/vbnet/
http://www.mvps.org/ccrp/


| Not so:
|
|     Open "c:\autoexec.bat" For Input As 1
|     Text1 = Input(LOF(1), 1)
|     Seek 1, 1
|     Text2 = Input(LOF(1), 1)
|     Close
|
| Perfectly legal.
|
| LFS
|
| >
| > On a sequential file ?  Seek requires a Binary open, right?
| >
| > --
| >
| > Randy Birch, MVP Visual Basic
| >
| > http://www.mvps.org/vbnet/
| > http://www.mvps.org/ccrp/

| >


| > | You have opened the file giving it a 'filenumber'.  Use that number
in:
| > |
| > | Seek #<filenumber>, 1
| > |
| > | LFS



Fri, 29 Mar 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. first record in query dumped when wrapping DataBind in While DataReader.Read() block

2. Crystal reports select expert can only read first 300 records from sybase

3. First dataset record read

4. losing records when first reading an Access database

5. Add records to without reading the table first????

6. Adding .TXT files to a VB program without the .TXT file

7. Read data from .TXT file

8. illegal Operation reading txt file str ?

9. Reading txt files in VBA

10. Reading External txt files

11. Problem to read a file txt

12. open txt file and read strings

 

 
Powered by phpBB® Forum Software