getting rid of unprintable chraracters...?

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

I have the following loop in a function to get rid of unprintable
chararcters (car ret, line feeds, etc) in a cell.
It works fine most of the time, but something is getting by it.
I keep running into a cell that has one char that always remain (I can
see it is taking up a space, but I cannot identify it).

Can I change this loop to leave only a-z A-Z 0-9?
Or at the very least, leave only chracters I can see?
Thnak you

Function eliminate_unprintable_chars(chars)
For i = 1 To Len(chars)
If Mid(chars, i, 1) > " " Then
...I have a good character here, now save it....
End If
Next i
End Function
 
The ascii code for " " is 32, so you are eliminating anything below 32 but
not above - and there are some very odd characters above the alphabet. 122
is "z" and above that are the strange things, although you might want 123-126
as well ("{","|","}","~" in Arial font). This would do that:
If Asc(Mid(chars, i, 1)) > 32 And Asc(Mid(chars, i, 1))<126 Then...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top