VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Another way to find and replace all instances of one string in another

by Jonathan (4 Submissions)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 23rd May 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Another way to find and replace all instances of one string in another

Rate Another way to find and replace all instances of one string in another



    Dim I As Integer
    I = 1
    Dim LeftPart
    Do While True
        I = InStr(1, Entire, Word)
        If I = 0 Then
            Exit Do
        Else
            LeftPart = Left(Entire, I - 1)
            Entire = LeftPart & Right(Entire, Len(Entire) - Len(Word) - Len(LeftPart))
        End If
    Loop
    MsgBox Entire
End Sub

Public Sub Form_Load()
    RemoveString "StringToSearch", "WordToRemove"
End Sub

Download this snippet    Add to My Saved Code

Another way to find and replace all instances of one string in another Comments

No comments have been posted about Another way to find and replace all instances of one string in another. Why not be the first to post a comment about Another way to find and replace all instances of one string in another.

Post your comment

Subject:
Message:
0/1000 characters