Dim dr As DataRow = e.DataRow Dim dt As DataTable =DataTables("学生成绩") If e.DataCol.Name = "班级" And dr.IsNull("班级") = False Then dr("语文_优") = dt.Compute("Count(姓名)", "班级 = '" & dr("班级") & "' and 语文 >= 90") dr("语文_良") = dt.Compute("Count(姓名)", "班级 = '" & dr("班级") & "' and 语文 >= 80 and 语文 < 90") End If