This tutorial will show you how to replace old text with new text in only one textbox. I use only one TextBox to store text and one Button with Click_Event to generate code.
No | Control type | Name | Text |
1 | Form1 | FormReplaceText | ReplaceText |
2 | TextBox1 | TextBoxString | |
3 | Button1 | ButtonReplace | Replace Text |
- As you see in this sample image above, when you type word "Human" in textbox"TextBoxString" and when you click on Button "Replace Text", the textbox will show "New Repalce: Human" because I coded "New Repalce: " & TextBoxString.Text in program to replace.
Code
Public Class FormReplaceText
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles ButtonReplace.Click
If TextBoxString.Text <> "" And
TextBoxString.Text.Contains(TextBoxString.Text) Then
TextBoxString.Text =
TextBoxString.Text.Replace(TextBoxString.Text, "New
Repalce: " & TextBoxString.Text)
End If
End Sub
End Class
0 comments:
Post a Comment