VB.NET – 从字符串中删除一个字符

前端之家收集整理的这篇文章主要介绍了VB.NET – 从字符串中删除一个字符前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个字符串:
  1. Dim stringToCleanUp As String = "bon;jour"
  2. Dim characterToRemove As String = ";"

我想要一个删除’;’的函数这样的角色:

  1. Function RemoveCharacter(ByVal stringToCleanUp,ByVal characterToRemove)
  2. ...
  3. End Function

这是什么功能

回答:

  1. Dim cleanString As String = Replace(stringToCleanUp,characterToRemove,"")

万分感谢!

  1. Function RemoveCharacter(ByVal stringToCleanUp,ByVal characterToRemove)
  2. ' replace the target with nothing
  3. ' Replace() returns a new String and does not modify the current one
  4. Return stringToCleanUp.Replace(characterToRemove,"")
  5. End Function

这里有更多关于VB’s Replace function的信息

猜你在找的VB相关文章