Dim str As String = "2015年8月收款15万元,支付8000元"
Dim s As String = System.Text.RegularExpressions.Regex.Match(str,"[0-9.]+(?=元+)").ToString()
需要的结果是:15万元,8000元
Dim str As String = "2015年8月收款15万元,支付8000元"
Dim s1 As String = System.Text.RegularExpressions.Regex.Match(str, "[0-9.]+(?=万元+)").ToString()
Dim s2 As String = System.Text.RegularExpressions.Regex.Match(str, "[0-9.]+(?=元+)").ToString()
MessageBox.Show(s1 & "万元," & s2 & "元")
Dim str As String = "2015年8月收款15万元,支付8000元"
Dim rgx = New System.Text.RegularExpressions.Regex("[0-9.]+[万元|元]+", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
For Each match As System.Text.RegularExpressions.Match In rgx.Matches(str)
Output.Show(match.Value)
Next
[此贴子已经被作者于2023/11/3 13:45:02编辑过]
单元格下拉取值后,再提取数据,如:下拉选取 “本项目总投资约4468300万元”,单元格最后的值为:“4468300万元” 代码写在哪里?

此主题相关图片如下:1699032248011.jpg

[此贴子已经被作者于2023/11/4 1:24:40编辑过]
放在DataColChanging 中没有用?
Select Case e.DataCol.Name
Case "项目概算"
If e.oldValue > ""
Dim str As String = e.OldValue
Dim rgx = New System.Text.RegularExpressions.Regex("[0-9.]+[万元|亿元]+", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
For Each match As System.Text.RegularExpressions.Match In rgx.Matches(str)
e.NewValue = match.Value
Next
End If
End Select
学会调试
Select Case e.DataCol.Name
Case "项目概算"
msgbox(e.oldValue)
msgbox(e.newvalue)
If e.oldValue > ""
Dim str As String = e.OldValue
msgbox(str )
Dim rgx = New System.Text.RegularExpressions.Regex("[0-9.]+[万元|亿元]+", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
For Each match As System.Text.RegularExpressions.Match In rgx.Matches(str)
msgbox(match.Value)
e.NewValue = match.Value
Next
End If
End Select