以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]那里错了?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=85450)

--  作者:tjnhjs
--  发布时间:2016/5/26 9:32:00
--  [求助]那里错了?
For j As Integer=5 To am-1
      Dim hm As String=Tables(ksmc).Cols(j).Name
      Dim ckrs As Integer=0
      Dim yxrs As Integer=0
      Dim hgrs As Integer=0

dr(hm & "_平均分") =  DataTables("单元测试1").Compute("Avg(语文)","学校 = \'" & nm(0) & "\' And [年级] = \'" & nm(1) & "\' And [班级] = \'" & nm(2) & "\'")
yxrs=DataTables("单元测试1").Compute("Count(语文)","语文>=90")  
   hgrs= DataTables("单元测试1").Compute("Count(语文)","语文>=60")    
ckrs= DataTables("单元测试1").Compute("Count(编号)")   
  dr(hm & "_优秀率") =  DataTables("单元测试1").Compute(yxrs/ckrs*100 ,"学校= \'" & nm(0) & "\' And [年级] = \'" & nm(1) & "\' And [班级] = \'" & nm(2) & "\'")    
dr(hm & "_合格率") =  DataTables("单元测试1").Compute(hgrs/ckrs*100 ,"学校= \'" & nm(0) & "\' And [年级] = \'" & nm(1) & "\' And [班级] = \'" & nm(2) & "\'")    
 Next 
红色部分计算结果不正确



--  作者:大红袍
--  发布时间:2016/5/26 9:36:00
--  
Dim filter As String = "学校 = \'" & nm(0) & "\' And [年级] = \'" & nm(1) & "\' And [班级] = \'" & nm(2) & "\'"
dr(hm & "_平均分") =  DataTables("单元测试1").Compute("Avg(语文)", filter)
yxrs=DataTables("单元测试1").Compute("Count(语文)","语文>=90 and " & filter)
hgrs= DataTables("单元测试1").Compute("Count(语文)","语文>=60 and " & filter)
ckrs= DataTables("单元测试1").Compute("Count(编号)", filter)
dr(hm & "_优秀率") = yxrs / ckrs
dr(hm & "_合格率") =  hgrs / ckrs

--  作者:tjnhjs
--  发布时间:2016/5/26 14:10:00
--  
如果把“语文”换成变量咋引用,我试了半天也不行。
--  作者:大红袍
--  发布时间:2016/5/26 14:12:00
--  

Dim bl As String = "语文"

 

yxrs=DataTables("单元测试1").Compute("Count(" & bl & ")", bl & ">=90 and " & filter)