Foxtable(狐表)用户栏目专家坐堂 → 如何写班级的排名公式


  共有22430人关注过本帖树形打印复制链接

主题:如何写班级的排名公式

帅哥哟,离线,有人找我吗?
狐狸爸爸
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2008/11/11 17:12:00 [显示全部帖子]

如果不改也可以:

CurrentTable.Filter= "[班级] = '" & pm(i) & "'" ''筛选

改为

CurrentTable.Filter= "[班级] = " & pm(i)

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2008/11/12 8:22:00 [显示全部帖子]

呵呵,我怎么测试才一秒左右啊。
用下面的代码应该好一点。
还有要注意不是所有的列都应该设置成双精度型,排名、班级、学号这样的列应该是整数型。

e.Form.Controls("Label1").text="请稍等,正在计时..."

dim timestart,timeend as date

timestart=date.now

Dim pm As List(Of String) = CurrentTable.DataTable.GetUniqueValues("","班级")

Dim pmc As Integer

Dim ColNames() As String = {"数学","英语","化学","物理","总分"}

Dim TotalName As String

CurrentTable.Redraw = False '刷新表

For Each ColName As string In ColNames

    For i As Integer = 0 To pm.Count -1

        CurrentTable.Filter= "[班级] = '" & pm(i) & "'"

        Currenttable.sort = ColName & " DESC"

        pmc = 0

        TotalName = ColName & "班级排名"

        For n As integer = 0 to Currenttable.rows.Count -1

            pmc = pmc +1

            If n > 0 AndAlso Currenttable.rows(n)(TotalName ) = Currenttable.rows(n-1)(TotalName ) Then

                CurrentTable.Rows(n)(TotalName ) = CurrentTable.Rows(n-1)(TotalName )

            Else

                CurrentTable.Rows(n)(TotalName ) = pmc

            End If

        Next

    Next

Next

Tables("学生各科成绩表").Sort = "总分 DESC" '排序,对总分列以降序排序

CurrentTable.Filter = "" '取消筛选

CurrentTable.Redraw = True '刷新表

timeend=date.now

e.Form.Controls("Label1").text="耗时" & (timeend-timestart).TotalSeconds & ""

Messagebox.Show("统计完毕!")



 下载信息  [文件大小:   下载次数: ]
点击浏览该文件:学生成绩统计分析表.rar

[此贴子已经被作者于2008-11-12 8:25:52编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2008/11/12 10:30:00 [显示全部帖子]

你这个里面没有年级列,如果要按年级排序,加上年级列,代码中的班级改为年级即可,原理一样。

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2008/11/12 11:59:00 [显示全部帖子]

e.Form.Controls("Label1").text="请稍等,正在计时..."

dim timestart,timeend as date

timestart=date.now

Dim pm As List(Of String) = CurrentTable.DataTable.GetUniqueValues("","班级")

Dim pmc As Integer

Dim ColNames() As String = {"数学","英语","化学","物理","总分"}

Dim TotalName As String

CurrentTable.Redraw = False '刷新表

For Each ColName As string In ColNames

    For i As Integer = 0 To pm.Count -1

        CurrentTable.Filter= "[班级] = " & pm(i)

        Currenttable.sort = ColName & " DESC"

        pmc = 0

        TotalName = ColName & "班级排名"

        For n As integer = 0 to Currenttable.rows.Count -1

            pmc = pmc +1

            If n > 0 AndAlso Currenttable.rows(n)(ColName) = Currenttable.rows(n-1)(ColName) Then

                CurrentTable.Rows(n)(TotalName ) = CurrentTable.Rows(n-1)(TotalName )

            Else

                CurrentTable.Rows(n)(TotalName ) = pmc

            End If

        Next

    Next

Next

Tables("学生各科成绩表").Sort = "总分 DESC" '排序,对总分列以降序排序

CurrentTable.Filter = "" '取消筛选

CurrentTable.Redraw = True '刷新表

timeend=date.now

e.Form.Controls("Label1").text="耗时" & (timeend-timestart).TotalSeconds & ""

Messagebox.Show("统计完毕!")

[此贴子已经被作者于2008-11-12 12:05:30编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2008/11/12 12:15:00 [显示全部帖子]

要快,就用这个,0.5秒:

e.Form.Controls("Label1").text="请稍等,正在计时..."

dim timestart,timeend as date

timestart=date.now

Dim pm As List(Of String) = CurrentTable.DataTable.GetUniqueValues("","班级")

Dim pmc As Integer

Dim ColNames() As String = {"数学","英语","化学","物理","总分"}

Dim TotalName As String

CurrentTable.Redraw = False '刷新表

For Each ColName As string In ColNames

    For i As Integer = 0 To pm.Count -1

        If pm(i) = "" Then

            Continue for

        End If

        Dim drs As List(Of DataRow) = Currenttable.DataTable.Select("[班级] = " & pm(i), ColName & " DESC")

        pmc = 0

        TotalName = ColName & "班级排名"

        For n As integer = 0 To drs.Count - 1

            pmc = pmc +1

            If n > 0 AndAlso drs(n)(ColName ) = drs(n-1)(ColName) Then

                drs(n)(TotalName ) = drs(n-1)(TotalName )

            Else

                drs(n)(TotalName ) = pmc

            End If

        Next

    Next

Next

Tables("学生各科成绩表").Sort = "总分 DESC" '排序,对总分列以降序排序

CurrentTable.Redraw = True '刷新表

timeend=date.now

e.Form.Controls("Label1").text="耗时" & (timeend-timestart).TotalSeconds & "秒"

Messagebox.Show("统计完毕!")



 


[本帖被加为精华]
 回到顶部