以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  我要把空值当做1,为什么不能正确计算呢  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=109486)

--  作者:whtb999
--  发布时间:2017/11/13 16:03:00
--  我要把空值当做1,为什么不能正确计算呢
Dim d1 As Double
Dim d2 As Double
Dim d3 As Double
Dim d4 As Double
Dim d5 As Double
d1=1
d2=1
d3=1
d4=1
Select Case e.DataCol.Name
    Case "第一列"
        If e.DataRow.IsNull("第一列") Then
            e.DataRow("第一列") = Nothing
            
        Else
            d1=e.DataRow("第一列")
            d5=d1*d2*d3*d4
            e.DataRow("第五列")=d5
        End If
    Case "第二列"
        If e.DataRow.IsNull("第二列") Then
            e.DataRow("第二列") = Nothing
        Else
            d2=e.DataRow("第二列")
            d5=d1*d2*d3*d4
            e.DataRow("第五列")=d5
        End If
        
    Case "第三列"
        If e.DataRow.IsNull("第三列") Then
            e.DataRow("第三列") = Nothing
        Else
            d3=e.DataRow("第三列")
            d5=d1*d2*d3*d4
            e.DataRow("第五列")=d5
        End If
        
    Case "第四列"
        If e.DataRow.IsNull("第四列") Then
            e.DataRow("第四列") = Nothing
        Else
            d4=e.DataRow("第四列")
            d5=d1*d2*d3*d4
            e.DataRow("第五列")=d5
        End If
End Select

--  作者:whtb999
--  发布时间:2017/11/13 16:13:00
--  
我这样修改了也不行不知道问题出在哪里,请各位帮忙
Dim d5 As Double
d1=1
d2=1
d3=1
d4=1
Select Case e.DataCol.Name
    Case "第一列"
        If e.DataRow.IsNull("第一列") Then
            e.DataRow("第一列") = Nothing
            d1=1
        Else
            d1=e.DataRow("第一列")
            d5=d1*d2*d3*d4
            e.DataRow("第五列")=d5
        End If
    Case "第二列"
        If e.DataRow.IsNull("第二列") Then
            e.DataRow("第二列") = Nothing
            d2=1
        Else
            d2=e.DataRow("第二列")
            d5=d1*d2*d3*d4
            e.DataRow("第五列")=d5
        End If
        
    Case "第三列"
        If e.DataRow.IsNull("第三列") Then
            e.DataRow("第三列") = Nothing
            d3=1
        Else
            d3=e.DataRow("第三列")
            d5=d1*d2*d3*d4
            e.DataRow("第五列")=d5
        End If
        
    Case "第四列"
        If e.DataRow.IsNull("第四列") Then
            e.DataRow("第四列") = Nothing
            d4=1
        Else
            d4=e.DataRow("第四列")
            d5=d1*d2*d3*d4
            e.DataRow("第五列")=d5
        End If
End Select

--  作者:有点甜
--  发布时间:2017/11/13 16:18:00
--  
Select Case e.DataCol.name
    Case "第一列","第二列","第三列","第四列"
        Dim d1 As Double = val(e.DataRow("第一列"))
        Dim d2 As Double = val(e.DataRow("第二列"))
        Dim d3 As Double = val(e.DataRow("第三列"))
        Dim d4 As Double = val(e.DataRow("第四列"))
        Dim d5 As Double
       
       
        If e.DataRow.IsNull("第一列") Then
            e.DataRow("第一列") = Nothing
            d1 = 1
        End If
       
        If e.DataRow.IsNull("第二列") Then
            e.DataRow("第二列") = Nothing
            d2 = 1
        End If
       
        If e.DataRow.IsNull("第三列") Then
            e.DataRow("第三列") = Nothing
            d3 = 1
        End If
        If e.DataRow.IsNull("第四列") Then
            e.DataRow("第四列") = Nothing
            d4 = 1
        End If
       
        d5=d1*d2*d3*d4
        e.DataRow("第五列")=d5
End Select

--  作者:whtb999
--  发布时间:2017/11/13 17:22:00
--  
谢谢您!