参考代码,如果有问题,单独贴出测试代码和数据,说明哪里有问题。
'Dim dtb As DataTable = DataTables("表e")
'Dim dtc As DataTable = DataTables("表k")
Dim ns As new List(of String)
ns.AddRange(new String() {"儿童","单房差","1-10号"})
'For Each dr As DataRow In dtb.DataRows
Dim str As String = "成人,1-10号,123(国线),儿童3170,单房差1570" 'dr("价格")
Dim arr() As String = str.Split(",")
str = ""
For Each Ar As String In arr
Dim n As String = ""
Dim p As Double = 0
For Each n1 As String In ns
If ar.Contains(n1) Then
n = n1
Exit For
End If
Next
If n > "" Then
p = val(ar.Replace(n,"")) - 10
If p = -10
str &= ar & ","
Else
str &= n & p & ","
End If
Else
str &= ar & ","
End If
Next
msgbox(str.trim(","))
'Dim ndr As DataRow = dtc.AddNew
'ndr("价格")=str
'Next