以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  自定义函数有误,如何修改?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=72073)

--  作者:cqlpjks
--  发布时间:2015/7/22 22:59:00
--  自定义函数有误,如何修改?
自定义函数:选做题科目名次执行时报错:
图片点击可在新窗口打开查看此主题相关图片如下:自定义函数报错.png
图片点击可在新窗口打开查看
如何修改?请指教!谢谢!
Dim kms() As String = Args(0)
Dim pm As List(Of String()) = CurrentTable.DataTable.GetValues("年级|选做","")
Dim pmc As Integer
Dim TotalName As String
CurrentTable.Redraw = False
For Each km As String In kms
    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) &  "\'", km & " DESC") \'字符型
        pmc = 0
        TotalName = km & "名次"
        For n As Integer = 0 To drs.Count - 1
            pmc = pmc +1
            If n > 0 AndAlso drs(n)(km ) = drs(n-1)(km) Then
                drs(n)(TotalName ) = drs(n-1)(TotalName )
            Else
                drs(n)(TotalName ) = pmc
            End If
        Next
    Next
Next
CurrentTable.Redraw = True
[此贴子已经被作者于2015/7/22 22:59:46编辑过]

--  作者:大红袍
--  发布时间:2015/7/22 23:04:00
--  

CurrentTable 表没有 年级 列。

 

表一定要对应。


--  作者:cqlpjks
--  发布时间:2015/7/22 23:08:00
--  
“语文”表中:
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:高中试卷难度区分度分析.rar

表是变化的。有可能是“数学”,“英语”.....
[此贴子已经被作者于2015/7/22 23:11:50编辑过]

--  作者:大红袍
--  发布时间:2015/7/22 23:27:00
--  

传入表名

 

Dim kms() As String = Args(0)
Dim tb As Table = Tables(args(1))
Dim pm As List(Of String()) = tb.DataTable.GetValues("年级|选做","")
Dim pmc As Integer
Dim TotalName As String
tb.Redraw = False
For Each km As String In kms
    For i As Integer = 0 To pm.Count -1
        If pm(i)(0) = "" Then
            Continue For
        End If
        Dim drs As List(Of DataRow) = tb.DataTable.Select("[年级] = \'" & pm(i)(0) & "\'And [选做] = \'" & pm(i)(1) &  "\'", km & " DESC") \'字符型
        pmc = 0
        TotalName = km & "名次"
        For n As Integer = 0 To drs.Count - 1
            pmc = pmc +1
            If n > 0 AndAlso drs(n)(km ) = drs(n-1)(km) Then
                drs(n)(TotalName ) = drs(n-1)(TotalName )
            Else
                drs(n)(TotalName ) = pmc
            End If
        Next
    Next
Next
tb.Redraw = True


--  作者:cqlpjks
--  发布时间:2015/7/22 23:53:00
--  
还是报错:
图片点击可在新窗口打开查看此主题相关图片如下:还是报错.png
图片点击可在新窗口打开查看
语文名次没填充进去。应该是内部函数“选做题科目名次”执行错误。
[此贴子已经被作者于2015/7/23 0:00:42编辑过]

--  作者:blackzhu
--  发布时间:2015/7/23 8:35:00
--  
Dim strr As String = Args(0)
Dim kms() As String = strr.split(",")
Dim tb As Table = Args(1)
Dim pm As List(Of String()) = tb.DataTable.GetValues("年级|选做","")
Dim pmc As Integer
Dim TotalName As String
tb.Redraw = False
For Each km As String In kms
    For i As Integer = 0 To pm.Count -1
        If pm(i)(0) = "" Then
            Continue For
        End If
        Dim drs As List(Of DataRow) = tb.DataTable.Select("[年级] = \'" & pm(i)(0) & "\'And [选做] = \'" & pm(i)(1) &  "\'", km & " DESC") \'字符型
        pmc = 0
        TotalName = km & "名次"
        For n As Integer = 0 To drs.Count - 1
            pmc = pmc +1
            If n > 0 AndAlso drs(n)(km) = drs(n-1)(km) Then
                drs(n)(TotalName) = drs(n-1)(TotalName)
            Else
                drs(n)(TotalName) = pmc
            End If
        Next
    Next
Next
tb.Redraw = True

Functions.Execute("选做题科目名次",填入的列名(也就是函数中km),Tables("语文"))
执行函数  
[此贴子已经被作者于2015/7/23 8:36:09编辑过]

--  作者:大红袍
--  发布时间:2015/7/23 9:26:00
--  

叫你把表名传进去啊

 

Functions.Execute("选做题科目名次",填入的列名,填入表名)


--  作者:cqlpjks
--  发布时间:2015/7/23 14:01:00
--  
搞定。谢谢!
Dim km As String = e.Form.Controls("科目").text
Dim s1() As String = New String() {""& km &""}
Dim dt As Table = Tables(Km)
Functions.Execute("科目排名",s1,dt)
Functions.Execute("选做题科目名次",km,dt)

我的表中“列名”与“科目名称”是相同的,s1与km应该是相同的。如表“语文”中的总分列我也是用的“语文”。