-
Hello, I uses this code(See below) to search a string for words and replace them, but when i want to search for a " and replace that, VB gets mad at me, and tells me that thats wrong.... any onw know how i can fix this?
Code:
Public Function ReplaceAll(ByVal searchString As Variant, findString As Variant, replaceString As Variant) As String
Dim strLeft As String
Dim strRight As String
Dim iFoundPos As Integer
strRight = searchString
If findString <> "" Then
Do While InStr(strRight, findString) <> 0
iFoundPos = InStr(strRight, findString)
strLeft = strLeft & Left(strRight, iFoundPos - 1) & replaceString
strRight = Right(strRight, Len(strRight) - (iFoundPos - 1) - Len(findString))
Loop
End If
ReplaceAll = strLeft & strRight
End Function
-
Maybe this function will work? http://www.vbsquare.com/tips/tip252.html
What VB version are you using? If it's VB6, you can use the Replace function.
-
Thanks
Thanks for the help, it works, and you i use VB6 and i don't realy know why i don't use Replace :)