在VB中,可以使用Replace方法來去掉字符串中的某個字符。具體語法如下:
Dim result As String = originalString.Replace(characterToRemove, "")
其中,originalString表示原始字符串,characterToRemove表示要去掉的字符,result即為去掉字符后的新字符串。
以下是一個完整的示例:
Dim originalString As String = "Hello, World!"
Dim characterToRemove As String = ","
Dim result As String = originalString.Replace(characterToRemove, "")
Console.WriteLine(result)
輸出結果為:“Hello World!”