Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共3 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:如何按性别排序

1楼
老有所乐 发表于:2009/1/8 23:17:00
请教
这是成绩表按班级排序代码,
Dim bjs As List(Of String) = DataTables("成绩表").GetUniqueValues("[班级] Is Not NULL","班级")
Dim Count As Integer
Dim ColNames() As String = {"语文","总分"}
Dim TotalName As String
For Each ColName As string In ColNames '
    For i As Integer = 0 To bjs.Count -1
        Dim drs As List(Of DataRow) = DataTables("成绩表").Select("[班级] = " & bjs(i), ColName & " DESC")
        Count = 0
        TotalName = ColName & "排名"
        For n As integer = 0 To drs.Count - 1
            Count = Count + 1
            If n > 0 AndAlso drs(n)(ColName ) = drs(n-1)(ColName) Then
                drs(n)(TotalName ) = drs(n-1)(TotalName )
            Else
                drs(n)(TotalName ) = Count
            End If
        Next
    Next
Next
Tables("成绩表").Sort = "总分 DESC"


如果不按班级排序,而是按性别排序,公式该如何修改,谢谢!
[此贴子已经被作者于2009-1-8 23:17:17编辑过]
2楼
czy 发表于:2009/1/9 0:13:00
没什么两样,只需将上述代码中的所有“班级”改“性别”。

另外性别的列属性应该是字符型,所以下面这段代码需更改

Dim drs As List(Of DataRow) = DataTables("成绩表").Select("[班级] = " & bjs(i), ColName & " DESC")

更正后即:

Dim drs As List(Of DataRow) = DataTables("成绩表").Select("[性别] = '" & bjs(i) & "'" , ColName & " DESC")

这样应该没有问题了。
3楼
老有所乐 发表于:2009/1/9 11:05:00

谢谢C版主!原来是这个'" & bjs(i) & "'" 问题

共3 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .01953 s, 2 queries.