以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]判断成绩为空则名次也为空。  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=175068)

--  作者:cqlpjks
--  发布时间:2022/2/18 11:30:00
--  [求助]判断成绩为空则名次也为空。
下面红色字体代码表示:如果成绩单元格为空则该成绩名次也为空,执行结果显示要么是1,要么是最后1名。如何修改代码?请指教。谢谢!
Tables("成绩库").StopRedraw
e.Form.Controls("Label1").text="排名中,请稍候..."
Dim Time,Time1 As Date
Time = Date.now
Dim pm As List(Of String()) = CurrentTable.DataTable.GetValues("年级|部别")
Dim pmc As Integer
Dim ColNames() As String = {"总分","总分1","语文","数学","英语","物理","历史","政治","政治1","地理","地理1","化学","化学1","生物","生物1"}
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)(0) = "" 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
            If ColName Is Nothing Then
                drs(n)(TotalName ) = Nothing
            Else
                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
            End If
        Next
    Next
Next
CurrentTable.Redraw = True
Time1 = Date.Now
e.Form.Controls("Label4").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"
e.Form.Controls("Label1").Text = "总分排名结束!"
Tables("成绩库").ResumeRedraw

--  作者:有点蓝
--  发布时间:2022/2/18 11:52:00
--  
            If drs(n).isnull(ColName ) Then
                drs(n)(TotalName ) = Nothing
            Else
                pmc = pmc +1

--  作者:cqlpjks
--  发布时间:2022/2/18 12:23:00
--  
谢谢!