Remplacer une caractère

Remplacer un ou plusieurs caractères

Alternative à la fonction 'Replace" apparue avec Access 2000
 

Function fReplace(ByVal strValue As String, _
                  ByVal strToReplace As String, _
                  ByVal strReplaceValue As String) As String
    Dim Position As Integer

    Position = InStr(strValue, strToReplace)

    Do While Position > 0
        strValue = Left(strValue, Position - 1) & strReplaceValue _
                   & Mid(strValue, Position + Len(strToReplace))
        Position = InStr(Position + Len(strReplaceValue), _
                         strValue, strToReplace, vbTextCompare)
    Loop

    fReplace = strValue

End Function


Dernière modification : 08/02/2010 02:00
Catégorie : Les mémos - String
Page lue 8432 fois