Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleReplace unwanted characters in a string using Replace
Keywordsreplace, character, remove, unwanted
CategoriesUtilities, Strings
 
Loop through the unwanted characters. For each, use Replace to replace it with a new value. This method has the advantage that it can replace unwanted characters with an empty string or more than one character.
 
' Replaces the characters set in strUnwanted as spaces
Public Function ReplaceCharacters(ByRef strText As String, _
    ByRef strUnwanted As String, ByRef strRepl As String) _
    As String
Dim i As Integer
Dim ch As String

    For i = 1 To Len(strUnwanted)
        ' Replace the i-th unwanted character.
        strText = Replace(strText, Mid$(strUnwanted, i, 1), _
            strRepl)
    Next

    ReplaceCharacters = strText
End Function
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated