Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


VB.net 4.5, Help with reading text file from "Generic Printer" to file

VB.net 4.5, Help with reading text file from "Generic Printer" to file

VB.net 4.5, Help with reading text file from "Generic Printer" to file

Company prints production tickets and then scans each Serial Number barcode into a software package. There are ~200 pages each day, so it takes time... I thought we could print them to a text file then I could grab out each Serial Number and save them to another file. however the word Serial Number is like so, a few letters on each line.

(as well as most other data in the file so finding anything is not so easy).

Can someone help me more efficient code, better code than try and look for "Ser" then "i" etc.


Using w As StreamWriter = File.AppendText(SpringFile)
                Me.ListBox1.Items.Add("Reading Print File")
                Dim objReader As New System.IO.StreamReader(FILE_NAME)
                Me.ListBox1.Items.Add("Writing Serial# file")
                Do While objReader.Peek() <> -1
                    Linedata = objReader.ReadLine()
                    If InStr(1, Linedata, "Ser") Then
                        'save to another text file
                        If InStr(1, Linedata, "Ser") Then
                            FindSerialNumberStart = InStr(1, Linedata, "Ser")

                            SerialNumber = Trim(Mid(Linedata, FindSerialNumberStart, 16))
                            w.WriteLine("*" & SerialNumber & "*")
                        End If

                       End if


RE: VB.net 4.5, Help with reading text file from "Generic Printer" to file

Maybe you could read the entire file into a temporary text file, stripping out all line breaks as you go. Then you should be able to find the words "Serial #" as a group and do whatever processing you need to do after that.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

RE: VB.net 4.5, Help with reading text file from "Generic Printer" to file

Thanks, luckily the serial numbers all end in "00" so I looked for 02000 and then 00 to find what I needed.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close