Dim sum As Double = 0 For Each dr As DataRow In DataTables("表A").Select("") Dim d As Date = dr("第一列") If d.DayOfWeek = 0 OrElse d.DayOfWeek = 6 Then If dr.IsNull("第二列") OrElse dr.IsNull("第三列") Then sum = sum + 1 End If Else If dr.IsNull("第二列") Then sum = sum + 1 End If If dr.IsNull("第三列") then sum = sum + 1 End If End If Next msgbox(sum)