Parsing Text File

Posted on 2003-12-09
Last Modified: 2010-05-01
I am trying to parse a text file in Visual Basic 6.
These are the steps that I am taking:

1. Open the input file for reading.
2. Open the output file for writing.
3. Read one line from input file.
4. Parse this line and filter out non-printing characters.
5. Write the line to the output file  

I need help on step 4.
Question by:fh2
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 9907016
what do u mean by non-printing characters
LVL 28

Accepted Solution

AzraSound earned 150 total points
ID: 9907030
What is a non-printing character?  One whose ASCII values falls outside of an acceptable range?  If its that simple, then you should be able to do something like:

For i = 1 To Len(strLineInput)
    If Asc(Mid(strLineInput, i, 1)) < 255 Then
        strLineOutput = strLineOutput & Mid(strLineInput, i, 1)
    End If

Print #1, strLineOutput

strLineOutput = ""

Expert Comment

ID: 9907078
shouldn't that be less than 127?

COuld he possibly also mean characters such as 'Bell' , 'DLE' etc ???

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 28

Expert Comment

ID: 9907113
I really had no idea so I just threw up the first "border" number that came to mind.  You're right though, other than Unicode characters, anything under 255 would include the entire ASCII table.

Author Comment

ID: 9907156
Non-printable characters are characters from 0 to 31 and 127 in standard ascii table.

Expert Comment

ID: 9907185
fh2 ,
Check out the ascii values and decide what you wish to keep and what you wish to replace

you can remove the characters with something along the lines of

strLine = Replace(strLine, Chr(7), "")   'Removes "Belll"


Expert Comment

ID: 9907199
If thats the case then Azra's code will work for you with only a slight modifications


Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Date Picker 64 bit 32 bit issue 12 63
Access Object Property from VBA Module in Excel 2010 2 39
clicking a shape in a frame array vb6 3 48
Advice in Xamarin 21 109
Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question