Replace()
Posted by: fredometro on
Jan 1st, 2004 |
Filed under: MS-Access
Replace a string by another string in a function. The function exists in Access 2000 and next, but not in Access 97. So here it is.
Public Function Replace(strSource As String, String1 As String, String2 As String) As String
Dim iLoc As Integer
Dim NewString As String
NewString = strSource
iLoc = InStr(NewString, String1)
Do While iLoc > 0
NewString = Left$(NewString, iLoc - 1) & String2 & Mid$(NewString, iLoc + 1)
iLoc = InStr(iLoc + 2, NewString, String1)
Loop
Replace = NewString
End Function
No related posts.

Tags:
Add A Comment
You must be logged in to post a comment.