A simple code to remove duplicate characters in a string. Is there any better solution?
Public Function DuplicateTrim(ByVal Value As String) As String
        Dim ASCII As Integer
        Dim Temp As String
        For ASCII = 33 To 126
            ' Get first location of the letter
            If InStr(1, Value, Chr(ASCII), CompareMethod.Binary) > 0 Then
 ' letter exists
 Temp &= Chr(ASCII)
 ' Remove all characters matching in original
 Value = Value.Replace(Chr(ASCII), "")
            End If
        Next
        Return Temp
End Function
 
 
No comments:
Post a Comment