以文本方式查看主题

-  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=34298)

--  作者:小兵
--  发布时间:2013/6/4 17:58:00
--  求助精简代码
Select Case e.DataCol.Name
Case "罪名"
If e.DataRow("罪名") Like "盗窃*" Then
e.DataRow("犯罪类型")="财产型"
ElseIf e.DataRow("罪名") Like "诈骗" Then
e.DataRow("犯罪类型") = "财产型"
ElseIf e.DataRow("罪名") Like "*诈骗*" Then
e.DataRow("犯罪类型")="财产型"
ElseIf e.DataRow("罪名") Like "*贪污*" Then
e.DataRow("犯罪类型")="财产型"
ElseIf e.DataRow("罪名") Like "*侵占*" Then
e.DataRow("犯罪类型") = "职务犯罪"
ElseIf e.DataRow("罪名") Like "*强奸*" Then
e.DataRow("犯罪类型")="淫欲型"
ElseIf e.DataRow("罪名") Like "*伤害*"  Then
e.DataRow("犯罪类型")="暴力型"
ElseIf e.DataRow("罪名") Like "*抢*" Then
e.DataRow("犯罪类型")="暴力型"
ElseIf e.DataRow("罪名") Like "*杀人*" Then
e.DataRow("犯罪类型") = "暴力型"
ElseIf e.DataRow("罪名") Like "*死*" Then
e.DataRow("犯罪类型") = "暴力型"
ElseIf e.DataRow("罪名") Like "*敲诈*" Then
e.DataRow("犯罪类型") = "暴力型"
ElseIf e.DataRow("罪名") Like "*淫*" Then
e.DataRow("犯罪类型") = "淫欲型"
Else
e.DataRow("犯罪类型")="其他型"
End If
End Select
这段代码怎么精简啊
--  作者:don
--  发布时间:2013/6/4 18:46:00
--  
Select Case e.DataCol.Name
    Case "罪名"
        Dim s1 As String = e.DataRow("罪名")
        Dim n1 As Integer
        If s1 = Nothing Then
            n1 = 1
        ElseIf "盗窃*|诈骗|贪污".Contains(s1) Then
            n1 =2
        ElseIf "伤害|抢|杀人|死|敲诈".Contains(s1) Then
            n1 =3
        ElseIf "淫|强奸".Contains(s1) Then
            n1 =4
        ElseIf "侵占".Contains(s1)  Then
            n1 =5
        Else
            n1 =6
        End If
        e.DataRow("犯罪类型") = choose(n1,"","财产型","暴力型","淫欲型", "职务犯罪","其他型")
End Select