从 vb.net 中的文本框中删除特定单词

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19178627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 15:21:00  来源:igfitidea点击:

Remove specific word from textbox in vb.net

vb.nettexttextbox

提问by user2846074

Is it possible to remove a specific word from a textbox in vb.net 2010

是否可以从 vb.net 2010 中的文本框中删除特定单词

example: i have a textbox that says "Hello World" and one that will copy it but only say "World"

示例:我有一个文本框,上面写着“Hello World”,一个文本框会复制它但只说“World”

my current code remove all letters.

我当前的代码删除所有字母。

textbox2.Text = New String(textbox2.Text.Except("Hello").ToArray())

thanks

谢谢

回答by sloth

Use String.Replace.

使用String.Replace.

textbox2.Text = textbox1.Text.Replace("Hello", "").Trim()

Except("Hello")will filter out each H, e, land oand is not what you want.

Except("Hello")将过滤掉每个H, e, lando不是你想要的。