以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  字符串比较(求简称)  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=184229)

--  作者:明天的灵
--  发布时间:2022/11/29 9:55:00
--  字符串比较(求简称)
表A的字段“公司全称”是完整的公司名称
表B的字段“公司简称”是完整的公司名称中的关键字,不重复
现要实际根据表B的公司简称,把表A所有行的公司简称填写上。
以下第6行写法报错,请指导

Dim s As String
Dim dr2 As DataRow
Dim i As Integer = 0
For Each dr1 As DataRow In DataTables("表A").datarows
    s = dr1("公司全称")
        Dr2 = DataTables("表B").Find("s like \'%" & 公司简称 & %\'")
    If dr2 Is Nothing Then
        MessageBox.Show("没有找到此公司:" & s)
     Else
         dr1("公司简称") = dr2("公司简称")
        i = i + 1
    End If
Next
MessageBox.Show("共替换:" & i & "个")

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:名称简称.table




--  作者:有点蓝
--  发布时间:2022/11/29 9:58:00
--  
Dr2 = DataTables("表B").Find("\'" & s & "\' like \'%\'+公司简称+\'%\'")
--  作者:明天的灵
--  发布时间:2022/11/29 10:12:00
--  
感谢蓝版主!!自己想了一晚上,都没有写对。感谢!!