Dim tbs() As String = { "表1", "表2"}
Dim cs1() As String = { "指标1", "指标2"}
Dim cs2() As String = { "指标A", "指标B", "指标C"}
Dim snum As Integer = Forms("窗口1").Controls("TextBox1").Text
Dim slen As Integer = Forms("窗口1").Controls("TextBox2").Text
Dim scount As Integer = Forms("窗口1").Controls("TextBox3").Text
Dim ls As new List(Of String())
ls.Add(cs1)
ls.add(cs2)
DataTables( "分组统计").DataRows.Clear
Dim dtb As New DataTableBuilder("分组统计")
dtb.AddDef("列名", Gettype(String), 32)
dtb.AddDef("标题", Gettype(String), 32)
For i As Integer = 1 To scount
dtb.AddDef("临时列" & i, Gettype(Double), "", snum+slen*(i-1) & "-" & snum+slen*i)
Next
dtb.Build()
For i As Integer = 0 To tbs.Length - 1
Dim cs As String() = ls(i)
For j As Integer = 0 To cs.Length - 1
Dim fdr = DataTables("分组统计").AddNew
fdr("列名") = cs(j)
fdr("标题") = Tables(tbs(i)).Cols(cs(j)).Caption
Dim All As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " is not null")
For Each dc As DataCol In DataTables("分组统计").datacols
If dc.Name Like "临时列*" Then
Dim ary() As String = dc.Caption.Split("-")
Dim c As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " >= " & ary(0) & " and " & cs(j) & " < " & ary(1) & " and " & cs(j) & " is not null")
fdr(dc.name) = c / All *100
End If
Next
Next
Next