欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp 自定义分段函数/求第N名成绩

程序员文章站 2022-07-05 19:29:18
复制代码 代码如下:function splitx(strs1 as string, strs2 as string, n as integer) '自定义分段函数 spl...
复制代码 代码如下:

function splitx(strs1 as string, strs2 as string, n as integer)

'自定义分段函数 splitx([字符串],"分隔符",第n段)
dim groupst() as string
groupst = split(strs1, strs2)
if ubound(groupst) < n - 1 then
splitx = 0
else
splitx = groupst(n - 1)
end if
end function

'/-------------------------------------
function minx(ksmc as string, lb as string, kmi as string, n as string)

'第n名的成绩 minx([考试名称],[类别],[科目],n)
dim con as object
dim rs as object
dim stsql as string
dim kmf as string
kmf = mid(kmi, 1, 1) & "组"

set con = application.currentproject.connection
set rs = createobject("adodb.recordset")
strsql = "select top 1 " & kmi & " as 达标分 from 成绩总表 "
strsql = strsql + " where ((( " & kmf & " ) <= " & n & ") and ((类别) = '" & lb & "' and 考试名称='" & ksmc & "'))"
strsql = strsql + " order by " & kmi
rs.open strsql, con, 3, 3
if rs.eof then
minx = 0
else
minx = rs("达标分")
end if
rs.close
set rs = nothing
set con = nothing
end function