以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  精简代码select case  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=73929)

--  作者:一笑
--  发布时间:2015/8/29 15:13:00
--  精简代码select case
求教,可否精简以下代码:
Select Case e.DataCol.Name
    Case "左座"
        Dim dr As DataRow = e.DataRow
        Dim h As String = dr("左座")
        Dim h2 As String = dr("飞行员")
        Dim h3 As String = dr("右座")
        Dim nms() As String = h2.Split(",")
        If nms.Length = 2 Then
            dr("右座") = h2.replace(h, "").replace(",", "")
        End If
    Case "右座"
        Dim dr As DataRow = e.DataRow
        Dim h As String = dr("左座")
        Dim h2 As String = dr("飞行员")
        Dim h3 As String = dr("右座")
        Dim nms() As String = h2.Split(",")        
        If nms.Length > 2 Then
            dr("观察员1") = h2.replace(h3 , "").replace(h, "").replace(",", "")
        End If
End Select


--  作者:czy
--  发布时间:2015/8/29 15:26:00
--  
Select Case e.DataCol.Name
    Case "左座","右座"
        Dim dr As DataRow = e.DataRow
        Dim h As String = dr("左座")
        Dim h2 As String = dr("飞行员")
        Dim h3 As String = dr("右座")
        Dim nms() As String = h2.Split(",")
        If nms.Length = 2 Then
            dr("右座") = h2.replace(h, "").replace(",", "")
        ElseIf nms.Length > 2 Then
            dr("观察员1") = h2.replace(h3 , "").replace(h, "").replace(",", "")
        End If
End Select
--  作者:有点蓝
--  发布时间:2015/8/29 15:27:00
--  
左座的 Dim h3 As String = dr("右座") 好像没用到
把没用到的去掉就行了,别再精简了