报错代码:报错提示:变量tp01在封闭中隐藏,Dim tp01 As Double = (dr("第1段") - dr2("第1段")).TotalSeconds(),如何解决,请老师,纠正,谢谢
Select Case e.DataCol.name
Case "第1段", "第2段", "第3段", "第4段", "第5段", "第6段"
Dim dr As DataRow = e.DataRow
If dr.IsNull("第1段") Then
dr("卡一") = Nothing
Else
Dim dr2 As DataRow = DataTables("时间").find("类别='" & dr("类别") & "'")
If dr2 IsNot Nothing Then
Dim tp01 As TimeSpan' 原来变量是tp1,报错提示:变量tp1在封闭中隐藏,以为是存在相同变量,改为tp01,还是报错提示:变量tp1在封闭中隐藏
If dr("第1段") > dr2("第1段") Then
Dim tp01 As Double = (dr("第1段") - dr2("第1段")).TotalSeconds()
dr("卡一") = tp01'
Else
tp01 = dr2("第1段").adddays(1) - dr("第1段")
End If
dr("卡一") = tp01.TotalSeconds() '
End If
Dim tp2 As TimeSpan
If dr("第2段") > dr2("第2段") Then
Dim tp2 As Double = (dr("第2段") - dr2("第2段")).TotalSeconds()
dr("卡二") = tp2'
Else
tp2 = dr2("第2段").adddays(1) - dr("第2段")
End If
dr("卡二") = tp2.TotalSeconds() '
End If
Dim tp3 As TimeSpan
If dr("第3段") > dr2("第3段") Then
Dim tp3 As Double = (dr("第3段") - dr2("第3段")).TotalSeconds()
dr("卡三") = tp3'
Else
tp3 = dr2("第3段").adddays(1) - dr("第3段")
End If
dr("卡三") = tp3.TotalSeconds() '
End If
Dim tp4 As TimeSpan
If dr("第4段") > dr2("第4段") Then
Dim tp4 As Double = (dr("第4段") - dr2("第4段")).TotalSeconds()
dr("卡四") = tp4
Else
tp4 = dr2("第4段").adddays(1) - dr("第4段")
End If
dr("卡四") = tp4.TotalSeconds() '
End If
Dim tp5 As TimeSpan
If dr("第5段") > dr2("第5段") Then
Dim tp5 As Double = (dr("第5段") - dr2("第5段")).TotalSeconds()
dr("卡五") = tp5'
Else
tp5 = dr2("第5段").adddays(1) - dr("第5段")
End If
dr("卡五") = tp5.TotalSeconds() '
End If
Dim tp6 As TimeSpan
If dr("第6段") > dr2("第6段") Then
Dim tp6 As Double = (dr("第6段") - dr2("第6段")).TotalSeconds()
dr("卡六") = tp6'
Else
tp6 = dr2("第6段").adddays(1) - dr("第6段")
End If
dr("卡六") = tp6.TotalSeconds() '
End If
End If
End Select