Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1253
  • Last Modified:

Parsing Text File

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
fh2
Asked:
fh2
1 Solution
 
dasariCommented:
what do u mean by non-printing characters
0
 
AzraSoundCommented:
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
 
mccainz2Commented:
shouldn't that be less than 127?

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

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
AzraSoundCommented:
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
 
fh2Author Commented:
Non-printable characters are characters from 0 to 31 and 127 in standard ascii table.
0
 
mccainz2Commented:
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
 
mccainz2Commented:
If thats the case then Azra's code will work for you with only a slight modifications


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now