私は話していません:
if textbox1.text.contains(textbox2.text) then
textbox1.text = ""
end if
でもこれは:
textbox1 に textbox2 にも存在する文字が含まれている場合、ボタンのクリック時に自動的に削除されます。
ありがとう、
次のようなものを使用できます
textbox1.Text = new String(textbox1.Text.Except(textbox2.Text).ToArray())
または単純なFor Each
ループ。
' btn click event
Dim unique As List(of String)
For i As Integer = 0 to textbox2.text.length - 1
Dim c As String = textbox2.text.substring(i,1)
If not unique.contains(c)
textbox1.text = textbox1.text.replace(c, "")
unique.add(c)
End If
Next For
次を使用することもできますRegex
。
textbox1.Text = Regex.Replace(textbox1.Text, _
"[" & Regex.Escape(textbox2.Text).Replace("-", "\-") & "]", "")