Dim Dic As new Dictionary(of DataRow, Integer)
Dim v As Double
For Each dr As DataRow In DataTables("表A").DataRows
v = DataTables("表A").Compute("Count(第二列 )", "第二列 = " & dr("第一列"))
dic.Add(dr, v)
Next
For Each dr As DataRow In dic.Keys
dr("第四列") = dic(dr)
Next
这段代码中,为什么不将
Dim Dic As new Dictionary(of DataRow, Integer)
直接定义为
Dim Dic As new Dictionary(of DataRow, Double)
否则V是double,而字典定义为integer,可能会导致数据截短.