Tables("试题").StopRedraw
Tables("试题").Filter = ""
Tables("试题").Sort = ""
For i As Integer = 0 To Tables("试题").rows.count -1
Tables("试题").Rows(i)("随机值") = Rand.Next(10000)
Next '排随机值
For Each dr As DataRow In DataTables("试题").DataRows
dr("信息") = Nothing
dr("序号") = Nothing
Next '清空指定列的数据
Dim fls As List(Of String) = DataTables("试题").GetUniqueValues("","分类")
Dim txs As List(Of String) = DataTables("试题").GetUniqueValues("","题型")
For Each fl As String In fls
For Each tx As String In txs
'获得该分类的全部行
Dim drs As List(Of DataRow) = DataTables("试题").Select("[分类] = '" & fl & "'" And "[题型] = '" & tx & "'", "随机值")
For n As Integer = 0 To drs.Count - 1 '遍历所有行
drs(n)("序号") = n + 1 '编号排序
Next
Next
Next
Dim Str As String
For Each fl As String In fls
For Each tx As String In txs
Dim dr As DataRow = DataTables("组题方式").Find("[模块] = '" & fl & "'" And "[题型] = '" & tx & "'")
'组合字符串
str = str & " or [分类] = '" & fl & "' And [组题] <= " & dr(Vars("考试类别"))*100
Next '筛选
Next
Tables("试题").Filter = str.SubString(4)
Tables("试题").Sort = "随机值,题型"
For i As Integer = 0 To Tables("试题").rows.count -1
Tables("试题").Rows(i)("序号") = i + 1
Next '对序号我按筛选行的顺序赋值
Tables("试题").ResumeRedraw
蓝总:内部函数运行时报错
此主题相关图片如下:微信截图_20220310124005.png