以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助] (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=86019) |
-- 作者:陈卫 -- 发布时间:2016/6/8 9:02:00 -- [求助] 专家好!我有当前表“表1”,包括以下列“A”、“B”、“C”、“D”,需要做以下工作: 1)判断“A”、“B”列的某行是否为空值,如果是空值,不做任何事情; 2)分别在“A”、“B”列输入数据,判断“B”列:如果“B”列中的该行数据=“甲”,则在“表2”中的“A”列,找到与当前表“表1”中“A”列对应的行,把“表2”中“M”列对应行的数据赋给“表1”中“C”列对应的行,把“表2”中“N”列对应行的数据赋给“表1”中“D”列对应的行. 否则,如果“B”列中的该行数据=“乙”,则在“表3”中的“A”列,找到与当前表“表1”中“A”列对应的行,把“表3”中“M”列对应行的数据赋给“表1”中“C”列对应的行,把“表3”中“N”列对应行的数据赋给“表1”中“D”列对应的行. 否则,如果“B”列中的该行数据=“丙”,则在“表4”中的“A”列,找到与当前表“表1”中“A”列对应的行,把“表4”中“M”列对应行的数据赋给“表1”中“C”列对应的行,把“表4”中“N”列对应行的数据赋给“表1”中“D”列对应的行. 以下程序编码如何改才能正确? Select Case e.DataCol.Name Case "A","D" If e.DataRow.IsNull("A") OrElse e.DataRow.IsNull("B") Then e.DataRow("C")=Nothing OrElse e.DataRow("D")=Nothing Else If e.DataRow.IsNull("B") ="甲" then Dim de As DataRow = e.DataRow Dim pe As DataRow = DataTables("表2").Find("A= \'" & de("A") & "\'") If pe IsNot Nothing Then de("C") = pe("M") de("D") = pe("N") End If Else If e.DataRow.IsNull("B") ="乙" then Dim de As DataRow = e.DataRow Dim pe As DataRow = DataTables("表3").Find("A= \'" & de("A") & "\'") If pe IsNot Nothing Then de("C") = pe(("M")) de("D") = pe("N") End If Else If e.DataRow.IsNull("B") ="丙" then Dim de As DataRow = e.DataRow Dim pe As DataRow = DataTables("表4").Find("A= \'" & de("A") & "\'") If pe IsNot Nothing Then de("C") = pe(("M")) de("D") = pe("N") End If End If End Select |
-- 作者:大红袍 -- 发布时间:2016/6/8 12:12:00 -- Select Case e.DataCol.Name Case "A","B" If e.DataRow.IsNull("A") OrElse e.DataRow.IsNull("B") Then e.DataRow("C")=Nothing e.DataRow("D")=Nothing ElseIf e.DataRow("B") ="甲" Then Dim de As DataRow = e.DataRow Dim pe As DataRow = DataTables("表2").Find("A= \'" & de("A") & "\'") If pe IsNot Nothing Then de("C") = pe("M") de("D") = pe("N") End If ElseIf e.DataRow("B") ="乙" Then Dim de As DataRow = e.DataRow Dim pe As DataRow = DataTables("表3").Find("A= \'" & de("A") & "\'") If pe IsNot Nothing Then de("C") = pe(("M")) de("D") = pe("N") End If ElseIf e.DataRow("B") ="丙" Then Dim de As DataRow = e.DataRow Dim pe As DataRow = DataTables("表4").Find("A= \'" & de("A") & "\'") If pe IsNot Nothing Then de("C") = pe(("M")) de("D") = pe("N") End If End If End Select |
-- 作者:陈卫 -- 发布时间:2016/6/8 15:05:00 -- 谢谢专家,问题解决了,但其中有这样的重复编码,这样合并成一段简单、不重复的? ElseIf e.DataRow("B") = "乙1" Then Dim de As DataRow = e.DataRow Dim pe As DataRow = DataTables("表3").Find("A= \'" & de("A") & "\'") If pe IsNot Nothing Then de("C") = pe("M") de("D") = pe("N") End If ElseIf e.DataRow("B") = "乙2" Then Dim de As DataRow = e.DataRow Dim pe As DataRow = DataTables("表3").Find("A= \'" & de("A") & "\'") If pe IsNot Nothing Then de("C") = pe("M") de("D") = pe("N") End If ElseIf e.DataRow("B") = "乙3" Then Dim de As DataRow = e.DataRow Dim pe As DataRow = DataTables("表3").Find("A= \'" & de("A") & "\'") If pe IsNot Nothing Then de("C") = pe("M") de("D") = pe("N") End If
|
-- 作者:大红袍 -- 发布时间:2016/6/8 19:16:00 -- Select Case e.DataCol.Name Case "A","B" If e.DataRow.IsNull("A") OrElse e.DataRow.IsNull("B") Then e.DataRow("C")=Nothing e.DataRow("D")=Nothing Else Dim de As DataRow = e.DataRow Dim pe As DataRow = DataTables("表2").Find("A= \'" & de("A") & "\'") If pe IsNot Nothing Then If e.DataRow("B") ="甲" Then de("C") = pe("M") de("D") = pe("N") ElseIf e.DataRow("B") ="乙" Then de("C") = pe(("M")) de("D") = pe("N") ElseIf e.DataRow("B") ="丙" Then de("C") = pe(("M")) de("D") = pe("N") End If End If End If End Select |