以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  结果为0 请帮忙检查一下。谢谢!!  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=95095)

--  作者:yigusheng
--  发布时间:2017/1/10 10:56:00
--  结果为0 请帮忙检查一下。谢谢!!
For Each tt As DataRow In DataTables("时间表").DataRows
    Dim d1 As Date = tt("开始时间")
    Dim d2 As Date = tt("结束时间")
    Dim d3 As Date = d1
    Dim w1 As Integer
    Dim w2 As Integer
    Dim w3 As Integer
    Dim w4 As Integer
    Dim w5 As Integer
   
    Do While d3<= d2
        Select Case d3.DayOfWeek
            Case 1
                w1 = w1 +1
            Case 2
                w2 = w2 +1
            Case 3
                w3 = w3 +1
            Case 4
                w4 = w4 +1
            Case 5
                w5 = w5 +1
        End Select
        d3 =d3.AddDays(1)
    Loop
   
    Select Case tt("星期")
        Case "星期一"
            tt("天数") = w1
        Case "星期二"
            tt("天数") = w2
        Case "星期三"
            tt("天数") = w3
        Case "星期四"
            tt("天数") = w4
        Case "星期五"
            tt("天数") = w5
    End Select
Next

--  作者:有点色
--  发布时间:2017/1/10 11:00:00
--  
 代码是没有问题的,你的【星期】列,如果填入了正确的【星期一】之类的数据,就肯定能得到正确的答案。