Results 1 to 3 of 3

Thread: Replace a string!!!

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jan 2001
    Location
    Sweden
    Posts
    38
    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

  2. #2
    Guest
    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.

  3. #3

    Thread Starter
    Registered User
    Join Date
    Jan 2001
    Location
    Sweden
    Posts
    38

    Thanks

    Thanks for the help, it works, and you i use VB6 and i don't realy know why i don't use Replace

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width