Foxtable(狐表)用户栏目专家坐堂 → 对导入后的数据进行排序


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

主题:对导入后的数据进行排序

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


加好友 发短信
等级:小狐 帖子:382 积分:3007 威望:0 精华:0 注册:2012/8/30 16:09:00
对导入后的数据进行排序  发帖心情 Post By:2013/4/22 7:46:00 [显示全部帖子]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:月考成绩管理.rar

大家好,前段时间学习完了小白的教程,感觉挺受用的。在此系统中的成绩排名表窗体的设计思路是:先导入数据,然后再对所导入的数据进行排序。可是当单击排序按钮式没有实现效果,请大侠们指导。谢谢!图片点击可在新窗口打开查看

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


加好友 发短信
等级:小狐 帖子:382 积分:3007 威望:0 精华:0 注册:2012/8/30 16:09:00
  发帖心情 Post By:2013/4/22 9:35:00 [显示全部帖子]

在“成绩排名表”窗体中的“按期数和班级排名”按钮代码如下:

''e.Form.Controls("Label3").text="排名中,请稍候..."
'Dim Time,Time1 As Date
'Time = Date.now
'Application.Doevents
'DataTables("成绩排名表").DataRows.Clear()
'Dim f As New Filler
'f.SourceTable = DataTables("成绩信息表")
'f.SourceCols = "月考期数,年级,班别,学号,姓名,语文,数学,英语,物理,化学,生物,政治,历史,地理,总分"
'f.DataTable = DataTables("成绩排名表")
'f.DataCols = "月考期数,年级,班别,学号,姓名,语文,数学,英语,物理,化学,生物,政治,历史,地理,总分"
'f.ExcludeExistValue = True
'f.ExcludeNullValue = True
'f.Fill
'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)(0) & "'And [班别] = " & pm(i)(1), 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
'Time1 = Date.Now
''e.Form.Controls("Label3").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"

 

e.Form.Controls("Label3").text="排名中,请稍候..."
Dim Time,Time1 As Date
Time = Date.now
Application.Doevents
DataTables("成绩排名表").DataRows.Clear()
Dim f As New Filler
f.SourceTable = DataTables("成绩信息表")
f.SourceCols = "月考期数,年级,班别,学号,姓名,语文,数学,英语,物理,化学,生物,政治,历史,地理,总分"
f.DataTable = DataTables("成绩排名表")
f.DataCols = "月考期数,年级,班别,学号,姓名,语文,数学,英语,物理,化学,生物,政治,历史,地理,总分"
f.ExcludeExistValue = True
f.ExcludeNullValue = True
f.Fill
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)(0) & "'And [班别] = '" & pm(i)(1), 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
Time1 = Date.Now
e.Form.Controls("Label3").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"

 

可是在单击“确定”按钮时提示如图的错误。


图片点击可在新窗口打开查看此主题相关图片如下:捕获.jpg
图片点击可在新窗口打开查看

这是怎么回事呢?谢谢!


 回到顶部