您可以使用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