CodeItBetter Programming Another VB Programming Blog

How to remove Duplicate characters from a string

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
'String Manipulation - How to remove Duplicate characters from a string
Option Explicit
 
'For example, If you want to remove Duplicate spaces from the string

Public Function RemoveDuplicateChar(ByVal Expression As String, _
    Optional ByVal sChar As String = " ") As String
    Do While InStr(Expression, String(2, sChar)) <> 0
        Expression = Replace(Expression, String(2, sChar), sChar)
    Loop
    RemoveDuplicateChar = Expression
End Function
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.