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

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now