VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Another way to find and replace all instances of one string in another (non case-sensitive)

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 (non case-sensitive)

Rate Another way to find and replace all instances of one string in another (non case-sensitive)



    Dim I As Integer
    I = 1
    Dim LeftPart
    Do While True
        I = InStr(1, Ucase$(Entire), Ucase$(Word))
        'This is case sensitive. To make it not case-sensitive:
        '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 (non case-sensitive) Comments

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

Post your comment

Subject:
Message:
0/1000 characters