4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by ChrisPadgham
2

See if this helps :

Dim StartPos, Counter As Integer
    Dim FindString, ReplaceText As String
    FindString = "test"
    ReplaceText = "MyString"
     
    For Counter = 1 To Len(Text1.Text)
            StartPos = InStr(Text1.Text, FindString)
            If StartPos > 0 Then
                    Text1.SelStart = StartPos - 1
                    Text1.SelLength = Len(FindString)
                    Text1.SelText = "" + ReplaceText
            End If
    Next
Votes + Comments
Yes. This code very helpful.
0

As Waltp says, if you want to replace the whole contents of the text box or if you only want to replace a substring in the text box

text1.text = replace(text1.text,"original","new)

Replace function documented here

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.