Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing IBM Characters

Status
Not open for further replies.

APElliott

Technical User
Jul 9, 2002
165
GB
Hello,

Could anyone tell me if there's a way of finding all IBM characters ie. ², °, `, ½, ¼, etc.... and replacing them with nothing.

Thanks,

Andrew [afro]
 
You can use the Asc() function to find out what a character's ASCII value is. Get or make a list of the characters you want to replace, then put that list in the following sample code. You should be able to pass a string to a function that does something like this:

Code:
Function DeleteChars(SourceString As String)
Dim x, y
For x = 1 To Len(SourceString)
   Select Case Asc(Mid(SourceString, x, 1))
   Case 12, 14, 22, 33 ' Do Nothing. (Replace these
      ' numbers with a list of the ASCII values of
      ' the characters you want to delete.)
   Case Else
      y = y & Mid(SourceString, x, 1)
   End Select
Next x
DeleteChars = y
End Function

Hope that helps you!

Luke

VBAjedi [swords]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top