以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关于简码的问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=71111)

--  作者:hongyefor
--  发布时间:2015/7/5 14:45:00
--  关于简码的问题

假设为A表,第一列为“公司名”,第二列为“简码”我想要提取“公司名”列里的第3个字开始做为简码,限制为6个英文字母(需要大写)后面加3个数字

请问这事件代码怎么写呢?


--  作者:大红袍
--  发布时间:2015/7/5 14:55:00
--  

 If e.DataCol.Name = "第一列" Then
    If e.newValue.Length > 3 Then
        Dim str As String = GetPy(e.NewValue.SubString(3),True)
        If str.Length > 6 Then str = str.SubString(0,6)
        e.DataRow("第二列") = str.ToUpper
    Else
        e.DataRow("第二列") = Nothing
    End If
Else
    e.DataRow("第二列") = Nothing
End If


--  作者:hongyefor
--  发布时间:2015/7/5 15:11:00
--  
呃,有问题,当删除有数据行的时候跳出错误,如果多行复制是就会关闭
图片点击可在新窗口打开查看此主题相关图片如下:错误.jpg
图片点击可在新窗口打开查看

--  作者:大红袍
--  发布时间:2015/7/5 15:23:00
--  
If e.DataCol.Name = "第一列" Then
    If e.newValue.Length > 3 Then
        Dim str As String = GetPy(e.NewValue.SubString(3),True)
        If str.Length > 6 Then str = str.SubString(0,6)
        e.DataRow("第二列") = str.ToUpper
    Else
        e.DataRow("第二列") = Nothing
    End If
End If

--  作者:czy
--  发布时间:2015/7/5 15:27:00
--  
If e.DataCol.Name = "第一列" Then
    If e.DataRow.IsNull("第一列") = False
        If e.newValue.Length > 3 Then
            Dim str As String = GetPy(e.NewValue.SubString(3),True)
            If str.Length > 6 Then str = str.SubString(0,6)
            e.DataRow("第二列") = str.ToUpper
        Else
            e.DataRow("第二列") = Nothing
        End If
    Else
        e.DataRow("第二列") = Nothing
    End If
End If

--  作者:hongyefor
--  发布时间:2015/7/5 15:29:00
--  

删除数据是还是有错误(不是删除行)


图片点击可在新窗口打开查看此主题相关图片如下:错误2.jpg
图片点击可在新窗口打开查看


--  作者:czy
--  发布时间:2015/7/5 15:30:00
--  
5楼应该不会出错的
--  作者:hongyefor
--  发布时间:2015/7/5 15:32:00
--  

还有能不能去掉企业名称里的()呢?

比如说 西门子(中国)有限公司  它会显示 Z(ZG)Y,但是我的目的是 ZZGYXG


--  作者:大红袍
--  发布时间:2015/7/5 15:36:00
--  

DataColChanged事件

 

\'\'\'...
If e.DataCol.Name = "第一列" Then
    If e.DataRow.IsNull("第一列") = False
        Dim str As String = e.NewValue.Replace("(", "").replace(")", "").Replace("(", "").replace(")", "")
        If str.Length > 3 Then
            str = GetPy(str.SubString(3),True)
            If str.Length > 6 Then str = str.SubString(0,6)
            e.DataRow("第二列") = str.ToUpper
        Else
            e.DataRow("第二列") = Nothing
        End If
    Else
        e.DataRow("第二列") = Nothing
    End If
End If