How to use Replace function for VB5
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 'String Manipulation - How to use Replace function for VB5 'If you are using VB5 and need Replace function that's available only in VB6, 'here is my version of it. Please let me know what you think. Function fnReplace(ByVal InWhat As String, What As String, WithWhat As String) As String Dim Pos As Long Pos = InStr(InWhat, What) While Pos fnReplace = fnReplace & Left(InWhat, Pos - 1) & WithWhat InWhat = Right(InWhat, Len(InWhat) - Pos - Len(What) + 1) Pos = InStr(InWhat, What) Wend fnReplace = fnReplace & InWhat End Function |