Hi masters,
I want to replace a string with another string in textbox
How i can do this?
Please help

Thank you

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
commented: Yes. This code very helpful. +3

Just load the new string into Text1.Text

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.