Foxtable(狐表)用户栏目专家坐堂 → [求助]成绩转换等级排除空值(缺考)代码


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

主题:[求助]成绩转换等级排除空值(缺考)代码

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/5/18 23:45:00 [显示全部帖子]

Dim ksmc As String = e.Form.Controls("ComboBox01").text
DataTables("学生成绩库").LoadFilter = "[考试名称] = '" & ksmc & "'"
DataTables("学生成绩库").Load()

Dim vals() As Double = {0.2,0.5,0.9}
Dim nms() As String = {"政治","语文","数学","英语"}
Dim cnt As Integer = DataTables("学生成绩库").DataRows.count
For Each nm As String In nms
    Dim drs As List (of DataRow) = DataTables("学生成绩库").Select(nm & " <> 0 And " & nm & " Is not null", nm & " Desc")
    Dim dn As String = nm & "等级"
    For i As Integer = 0 To drs.count - 1
        Dim v As Double = i /cnt
        If v > vals(2) Then
            drs(i)(dn) = "D"
        ElseIf v > vals(1) Then
            drs(i)(dn) = "C"
        ElseIf v > vals(0) Then
            drs(i)(dn) = "B"
        Else
            drs(i)(dn) = "A"
        End If
    Next
    DataTables("学生成绩库").ReplaceFor("等级", "缺考", nm & " = 0 or " & nm & " Is null")
Next


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/5/19 22:09:00 [显示全部帖子]

Dim ksmc As String = e.Form.Controls("ComboBox01").text
DataTables("学生成绩库").LoadFilter = "[考试名称] = '" & ksmc & "'"
DataTables("学生成绩库").Load()

Dim vals() As Double = {0.2,0.5,0.9}
Dim nms() As String = {"政治","语文","数学","英语"}
For Each nm As String In nms
    Dim drs As List (of DataRow) = DataTables("学生成绩库").Select(nm & " <> 0 And " & nm & " Is not null", nm & " Desc")
    Dim dn As String = nm & "等级"
    Dim cnt As Integer = drs.Count
    For i As Integer = 0 To drs.count - 1
        Dim v As Double = i /cnt
        If v > vals(2) Then
            drs(i)(dn) = "D"
        ElseIf v > vals(1) Then
            drs(i)(dn) = "C"
        ElseIf v > vals(0) Then
            drs(i)(dn) = "B"
        Else
            drs(i)(dn) = "A"
        End If
    Next
    DataTables("学生成绩库").ReplaceFor("等级", "缺考", nm & " = 0 or " & nm & " Is null")
Next


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/5/20 22:01:00 [显示全部帖子]

 上传例子。

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/5/20 22:06:00 [显示全部帖子]

Dim ksmc As String = e.Form.Controls("ComboBox01").text
DataTables("学生成绩库").LoadFilter = "[考试名称] = '" & ksmc & "'"
DataTables("学生成绩库").Load()

Dim vals() As Double = {0.2,0.5,0.9}
Dim nms() As String = {"政治","语文","数学","英语"}
For Each nm As String In nms
    Dim drs As List (of DataRow) = DataTables("学生成绩库").Select(nm & " <> 0 And " & nm & " Is not null", nm & " Desc")
    Dim dn As String = nm & "等级"
    Dim cnt As Integer = drs.Count
    Dim pnm As Double = 0
    Dim pdn As String = ""
    For i As Integer = 0 To drs.count - 1
        If drs(i)(nm) = pnm Then
            drs(i)(dn) = pdn
        Else
            Dim v As Double = i /cnt
            If v > vals(2) Then
                drs(i)(dn) = "D"
            ElseIf v > vals(1) Then
                drs(i)(dn) = "C"
            ElseIf v > vals(0) Then
                drs(i)(dn) = "B"
            Else
                drs(i)(dn) = "A"
            End If
            pnm = drs(i)(nm)
            pdn = drs(i)(dn)
        End If
    Next
    DataTables("学生成绩库").ReplaceFor("等级", "缺考", nm & " = 0 or " & nm & " Is null")
Next

 


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/5/20 22:28:00 [显示全部帖子]

看7楼。


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/5/20 22:32:00 [显示全部帖子]

 

Dim vals() As Double = {0.2,0.5,0.9}
Dim nms() As String = {"政治","语文","数学","英语"}
For Each nm As String In nms
    Dim drs As List (of DataRow) = DataTables("学生成绩库").Select(nm & " <> 0 And " & nm & " Is not null", nm & " Desc")
    Dim dn As String = nm & "等级"
    Dim cnt As Integer = drs.Count
    Dim pnm As Double = 0
    Dim pdn As String = ""
    For i As Integer = 0 To drs.count - 1
        If drs(i)(nm) = pnm Then
            drs(i)(dn) = pdn
        Else
            Dim v As Double = i /cnt
            If v > vals(2) Then
                drs(i)(dn) = "D"
            ElseIf v > vals(1) Then
                drs(i)(dn) = "C"
            ElseIf v > vals(0) Then
                drs(i)(dn) = "B"
            Else
                drs(i)(dn) = "A"
            End If
            pnm = drs(i)(nm)
            pdn = drs(i)(dn)
        End If
    Next
    DataTables("学生成绩库").ReplaceFor(nm & "等级", "缺考", nm & " = 0 or " & nm & " Is null")
Next


 回到顶部