以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]datacolchanged事件  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=149022)

--  作者:天一生水
--  发布时间:2020/4/21 16:14:00
--  [求助]datacolchanged事件
1、规范单元格内容中的标点符号:张三;李四;王五;;AAA;BBB
                                       为:张三、李四、王五;AAA、BBB

2、datacolchanged代码:
\'\'\'
If e.DataCol.Name = "第一列" Then    
    If e.NewValue IsNot Nothing Then
        e.DataRow("第一列") = e.DataRow("第一列").Replace(";","、").Replace("、、",";")
    End If
End If

结果成了:张三、李四、王五、AAA、BBB

3、如果在命令窗口执行下列代码,结果是正确的:
\'\'\'
Dim str As String  = "张三;李四;王五;;AAA;BBB"
str =str.Replace(",","、").Replace(",","、").Replace(";","、").Replace("、、",";")
msgbox(str)

这是哪里的问题?

--  作者:有点蓝
--  发布时间:2020/4/21 16:27:00
--  
\'\'\'
If e.DataCol.Name = "第一列" Then
    If e.NewValue IsNot Nothing Then
        systemready = False
        e.DataRow("第一列") = e.DataRow("第一列").Replace(";","、").Replace("、、",";")
        systemready = True
    End If
End If