VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Find one string in another, and replace them with a third string

by Francisco Castillo (2 Submissions)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 9th October 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Find one string in another, and replace them with a third string

Rate Find one string in another, and replace them with a third string



' By Francisco Castillo - september 2000
' Replaces the string "findStr" found in "target" with
' "replaceStr". Returns the resultant string.
    FindReplace = target
' Returns "target" if no ocurrence of "FindStr" found.
    p = InStr(target, findStr)
    If p <> 0 Then
        FindReplace = Left(target, p - 1) & replaceStr & Right(target, Len(target) - ((p - 1) + Len(findStr)))
    End If

End Function


Download this snippet    Add to My Saved Code

Find one string in another, and replace them with a third string Comments

No comments have been posted about Find one string in another, and replace them with a third string. Why not be the first to post a comment about Find one string in another, and replace them with a third string.

Post your comment

Subject:
Message:
0/1000 characters