RockGuitarist1 RockGuitarist1 - 4 months ago 20
Vb.net Question

How to Remove Specific Text from Combobox Items

What I want to do is be able to remove a section of a string and use the remaining portion of it to add to a Combobox.

Dim randString As String = ""
textbox.text = "(Remove this) - Keep this"
randString = textbox.text.... ' Trim/Split the first portion off somehow?
combobox.items.add(randString)

' Result should look like " - Keep this"


I've tried Trim/Split without any luck. Could anyone point me in the right direction? Thanks.

Answer

If you just want to remove a portion of the string, you can use the Replace function:

randString = Replace(textbox.text, "(Remove this)", "")

You can put any string variable in as the second argument.