如果您知道价格中包含字符串中唯一的美元符号,则可以使用String.Split和String.Join,任何更复杂的内容都可能需要正则表达式。
像这样。
Module Module1
Sub Main()
Dim x As Integer
Dim myString As String = "You're eligible to receive a discount of $10.00 today."
Dim temp As String() = myString.Split(" "c)
For x = 0 To temp.Length - 1
If temp(x).Contains("$") Then
temp(x) = "" & temp(x) & ""
End If
Next
myString = String.Join(" ", temp)
Console.WriteLine(myString)
Console.ReadLine()
End Sub
End Module
修改了GetText函数
Function GetText() As String
Dim strText As String = dataset1.Tables(0).Rows(0)("displayText").ToString()
Dim temp As String() = strText.Split(" "c)
For x = 0 To temp.Length - 1
If temp(x).Contains("$") Then
temp(x) = "" & temp(x) & ""
End If
Next
Return strText = String.Join(" ", temp)
End Function