Convertir accentué

Convertir les caractères accentués d'une chaîne de caractères

Les utilisations sont multiples, dans des requêtes ou dans n'importe quel autre objet...

Public Function fSupprimeAccents(ByVal Chaine As String) As String
    Dim Position As Integer

    For Position = Len(Chaine) To 1 Step -1
        Select Case Mid(Chaine, Position, 1)
            Case "à", "á", "â", "ã", "ä", "å", "Ä"
                Chaine = Left(Chaine, Position - 1) & "a" & Mid(Chaine, Position + 1)
            Case "ç"
                Chaine = Left(Chaine, Position - 1) & "c" & Mid(Chaine, Position + 1)
            Case "é", "è", "ë", "ê"
                Chaine = Left(Chaine, Position - 1) & "e" & Mid(Chaine, Position + 1)
            Case "ì", "í", "î", "ï"
                Chaine = Left(Chaine, Position - 1) & "i" & Mid(Chaine, Position + 1)
            Case "ñ"
                Chaine = Left(Chaine, Position - 1) & "n" & Mid(Chaine, Position + 1)
            Case "ò", "ó", "ô", "õ", "ö"
                Chaine = Left(Chaine, Position - 1) & "o" & Mid(Chaine, Position + 1)
            Case "ù", "ú", "û", "ü"
                Chaine = Left(Chaine, Position - 1) & "u" & Mid(Chaine, Position + 1)
            Case "ý", "ÿ"
                Chaine = Left(Chaine, Position - 1) & "y" & Mid(Chaine, Position + 1)
        End Select
    Next Position
    fSupprimeAccents = Chaine

End Function


Dernière modification : 08/02/2010 01:57
Catégorie : - String
Page lue 7897 fois