以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  判断所填内容自动按规则填写另一字段  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=146022)

--  作者:andyd
--  发布时间:2020/2/14 13:20:00
--  判断所填内容自动按规则填写另一字段
top颜色 的值可能是wwc w wc acc c ac cgc cg g,希望通过在填写top颜色时判断所填内容 自动填写topc,top颜色为空时 topc 为空,包含w时 topc 为 w,包含g时 topc 为g,非空又不包含g w时为c。
下面的代码在DataColChanged事件,当top颜色非空时只输出 c,清空top颜色时报错。帮忙看看怎么写,谢谢。

Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
    Case "top颜色"
If e.NewValue Is Nothing Then 
            dr("topc") = Nothing
        If e.newvalue.contains("W") Then
            dr("topc") = "W"
        If e.newvalue.contains("G") Then
            dr("topc") = "G"
            Else
            dr("topc") = "C"
        End If
        End If
        End If
End Select
[此贴子已经被作者于2020/2/14 13:24:09编辑过]

--  作者:有点蓝
--  发布时间:2020/2/14 13:37:00
--  
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
    Case "top颜色"
        If e.NewValue Is Nothing Then
            dr("topc") = Nothing
        Else
            If e.newvalue.contains("W") Then
                dr("topc") = "W"
            ElseIf e.newvalue.contains("G") Then
                dr("topc") = "G"
            Else
                dr("topc") = "C"
            End If
        End If
End Select