Read data from .TXT file 
Author Message
 Read data from .TXT file

I'm writing a help desk system in Access and need a little guidance.  I've
been using Access since 2.0 came out (now up to XP at home, 97 at the
office), so I'm pretty familiar with the basics, but I've just gotten into
actual module coding in the past year or so.

Anyway, what I need to do is take a text file, find a character string
within it, and pull that value into a variable for later use.  Below is a
sample of the files that I'll be using.  They'll all be the same format,
just a different service tag and asset number.  If someone could provide me
the code to strip out just this data, I'd be very appreciative!

<TEXTFILE>
ASSET  -- Version 1.08 (C) Copyright 1993-99 Dell Computer Corp.
Service Tag => B98SS
Asset Tag   => 6000062986
</TEXTFILE>

Thanks in advance,
Matt Schultz



Wed, 17 Dec 2003 01:33:06 GMT  
 Read data from .TXT file
The code below assumes that all the files read will be in the same format,
as in the ServiceTag will always be on the second line of the file and the
AssetTag will always be on the third line of the file. You may need to write
additional code to handle files that are not in the format you expect.

Private Sub ReadFile()
Dim strLine As String
Dim strServiceTag As String
Dim strAssetTag As String

    Open <FileName> For Input Access Read As #1
    Line Input #1, strLine

    Line Input #1, strServiceTag
    strServiceTag = Mid(strServiceTag, 16)

    Line Input #1, strAssetTag
    strAssetTag = Mid(strAssetTag, 16)
    Close #1

    MsgBox "Service Tag: " & strServiceTag & vbCrLf & "Asset Tag: " &
strAssetTag

End Sub

RJ


Quote:
> I'm writing a help desk system in Access and need a little guidance.  I've
> been using Access since 2.0 came out (now up to XP at home, 97 at the
> office), so I'm pretty familiar with the basics, but I've just gotten into
> actual module coding in the past year or so.

> Anyway, what I need to do is take a text file, find a character string
> within it, and pull that value into a variable for later use.  Below is a
> sample of the files that I'll be using.  They'll all be the same format,
> just a different service tag and asset number.  If someone could provide
me
> the code to strip out just this data, I'd be very appreciative!

> <TEXTFILE>
> ASSET  -- Version 1.08 (C) Copyright 1993-99 Dell Computer Corp.
> Service Tag => B98SS
> Asset Tag   => 6000062986
> </TEXTFILE>

> Thanks in advance,
> Matt Schultz



Wed, 17 Dec 2003 05:31:29 GMT  
 Read data from .TXT file
That was easy!  Thanks!

--Matt


Quote:
> The code below assumes that all the files read will be in the same format,
> as in the ServiceTag will always be on the second line of the file and the
> AssetTag will always be on the third line of the file. You may need to
write
> additional code to handle files that are not in the format you expect.

> Private Sub ReadFile()
> Dim strLine As String
> Dim strServiceTag As String
> Dim strAssetTag As String

>     Open <FileName> For Input Access Read As #1
>     Line Input #1, strLine

>     Line Input #1, strServiceTag
>     strServiceTag = Mid(strServiceTag, 16)

>     Line Input #1, strAssetTag
>     strAssetTag = Mid(strAssetTag, 16)
>     Close #1

>     MsgBox "Service Tag: " & strServiceTag & vbCrLf & "Asset Tag: " &
> strAssetTag

> End Sub

> RJ



> > I'm writing a help desk system in Access and need a little guidance.
I've
> > been using Access since 2.0 came out (now up to XP at home, 97 at the
> > office), so I'm pretty familiar with the basics, but I've just gotten
into
> > actual module coding in the past year or so.

> > Anyway, what I need to do is take a text file, find a character string
> > within it, and pull that value into a variable for later use.  Below is
a
> > sample of the files that I'll be using.  They'll all be the same format,
> > just a different service tag and asset number.  If someone could provide
> me
> > the code to strip out just this data, I'd be very appreciative!

> > <TEXTFILE>
> > ASSET  -- Version 1.08 (C) Copyright 1993-99 Dell Computer Corp.
> > Service Tag => B98SS
> > Asset Tag   => 6000062986
> > </TEXTFILE>

> > Thanks in advance,
> > Matt Schultz



Wed, 17 Dec 2003 09:17:03 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. reading data from .txt file

2. New to VB.Net--attempting to read txt file for Data Grid

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

4. export data from local txt file to .mdb file on server

5. illegal Operation reading txt file str ?

6. Reading txt files in VBA

7. Reading External txt files

8. Problem to read a file txt

9. open txt file and read strings

10. How to read a txt file?

11. how to read a txt file to text box

12. import txt files in Access fails to read last line

 

 
Powered by phpBB® Forum Software