以前的帖子:根据另一表格内容批量替换
http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=95391&page=2
当被替换的标的包含半角括号时,提示出错,见下图,比如,替换标的“(2016)”前边的括号为半角,后边的括号为全角。
此主题相关图片如下:image 3.jpg
附件:
替换代码如下:
Dim dt1 As DataTable = DataTables("数据表")
Dim dt2 As DataTable = DataTables("替换编辑")
For Each dr As DataRow In dt2.Select("")
For Each fdr As DataRow In dt1.Select("编号 = '" & dr("编号") & "'")
For Each dc As DataCol In dt1.DataCols
If dc.IsString Then
fdr(dc.name) = System.Text.RegularExpressions.Regex.replace(fdr(dc.name), dr("替换前内容"), dr("替换后内容"))
End If
Next
Next
Next