Reputation: 39
I am using following code to replace text
Text1.Text = Replace(quer, "demoo", "demo")
i am using multiline textbox which is filled up with 10lines of text
i just want to find and replace word "demoo" with "demo" on line 1 only
even if line2 or another lines contain "demoo", i just want to replace on line1
Upvotes: 0
Views: 53
Reputation: 993
Private Sub Command1_Click()
Dim lines() As String
If Len(Text1.Text) = 0 Then Exit Sub
lines = Split(Text1.Text, vbCrLf)
lines(0) = Replace(lines(0), "demoo", "demo")
Text1.Text = Join(lines, vbCrLf)
End Sub
Upvotes: 1
Reputation: 20464
You could use the TextBoxBase.Lines property.
Dim lines As String() = Me.TextBox1.Lines
lines(0) = lines(0).Replace("demoo", "demo")
Me.TextBox1.Lines = lines
Upvotes: 2