以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]嵌套循环计数  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=159851)

--  作者:jyh7081
--  发布时间:2021/1/11 16:58:00
--  [求助]嵌套循环计数
蓝老师好!
这段循环计数的代码, count0计数结果不对,是哪里问题?

\'\'\'
Dim count As Integer
Dim count0 As Integer

Dim Products As List(Of String)
Products = dt.GetValues("单位","标注 = true")
For Each Product As String In Products
    count = 0
     ......
    For Each r As DataRow In dt.Select("单位 = \'" & Product & "\' and 标注 = true")
                count +=1
    Next
    
    count0 +=count
Next

msgbox("批量接收 " & count0 & " 条记录")

--  作者:有点蓝
--  发布时间:2021/1/11 17:11:00
--  
不就是获取【标注 = true】的所有行数么,不需要这么复杂吧,一句代码就行了

msgbox(dt.compute("count(单位)","标注 = true"))