Solved

Parsing Text File

Posted on 2003-12-09
7
1,243 Views
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.
0
Comment
Question by:fh2
7 Comments
 
LVL 4

Expert Comment

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

Accepted Solution

by:
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
Next

Print #1, strLineOutput

'reset
strLineOutput = ""
0
 
LVL 5

Expert Comment

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

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

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 28

Expert Comment

by:AzraSound
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.
0
 

Author Comment

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

Expert Comment

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

http://www.asciitable.com/

you can remove the characters with something along the lines of

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

0
 
LVL 5

Expert Comment

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


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

943 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

1 Experts available now in Live!

Get 1:1 Help Now