Andrew Henz Andrew Henz - 1 month ago 8
Vb.net Question

VB.NET Get text from textbox without a specific string

How can I make something like in vb.net?
When Button 1 clicked:

Textbox1.text = "big banana"
dim string as string = "big"
MsgBox(Textbox1.Text without string)


Output: banana

Answer

You can do something like this. For example you have 2 textboxes the 1st one is the textbox that you will input the words you like and the second one is the textbox that you will use to remove a specific word in textbox1. Do something like this.

Dim StringToRemove as String = TextBox2.text
If Textbox1.Text.Contains(StringToRemove) then
Msgbox(TextBox1.Text.Replace(StringToRemove,"").Trim)
Else
Msgbox("The word you want to remove doesnt exist.")
End If

enter image description here

Sorry for the headers thats Sample 1 and Sample 2. At least you have a full working code with parameters with this one, checks if the word you want to remove exist.