📄 frmselecttest.frm
字号:
Caption = "分题干数为1的题"
Height = 180
Left = 1935
TabIndex = 37
Top = 2025
Width = 1350
End
Begin VB.Label Label16
AutoSize = -1 'True
Caption = "小题 每题"
Height = 180
Left = 2640
TabIndex = 31
Top = 3015
Width = 990
End
Begin VB.Label Label12
AutoSize = -1 'True
Caption = "小题 每题"
Height = 180
Left = 2640
TabIndex = 30
Top = 1680
Width = 990
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "小题 每题"
Height = 180
Left = 2640
TabIndex = 29
Top = 1275
Width = 990
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "小题 每题"
Height = 180
Left = 2640
TabIndex = 28
Top = 885
Width = 990
End
Begin VB.Label Label18
AutoSize = -1 'True
Caption = "分"
Height = 180
Left = 5820
TabIndex = 18
Top = 3015
Width = 180
End
Begin VB.Label Label17
AutoSize = -1 'True
Caption = "分 共"
Height = 180
Left = 4455
TabIndex = 17
Top = 3015
Width = 540
End
Begin VB.Label Label15
AutoSize = -1 'True
Caption = "4、程序填空"
Height = 180
Left = 900
TabIndex = 16
Top = 3015
Width = 990
End
Begin VB.Label Label14
AutoSize = -1 'True
Caption = "分"
Height = 180
Left = 5820
TabIndex = 15
Top = 1680
Width = 180
End
Begin VB.Label Label13
AutoSize = -1 'True
Caption = "分 共"
Height = 180
Left = 4455
TabIndex = 14
Top = 1680
Width = 540
End
Begin VB.Label Label11
AutoSize = -1 'True
Caption = "3、程序阅读"
Height = 180
Left = 900
TabIndex = 13
Top = 1680
Width = 990
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "分"
Height = 180
Left = 5820
TabIndex = 12
Top = 1275
Width = 180
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "分 共"
Height = 180
Left = 4455
TabIndex = 11
Top = 1275
Width = 540
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "2、选择题"
Height = 180
Left = 900
TabIndex = 10
Top = 1275
Width = 810
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "试卷名称"
Height = 180
Left = 900
TabIndex = 9
Top = 375
Width = 720
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "分"
Height = 180
Left = 5820
TabIndex = 6
Top = 885
Width = 180
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "分 共"
Height = 180
Left = 4455
TabIndex = 4
Top = 885
Width = 540
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "1、判断题"
Height = 180
Left = 900
TabIndex = 2
Top = 885
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "试卷总分"
Height = 180
Left = 4230
TabIndex = 0
Top = 375
Width = 720
End
End
Attribute VB_Name = "SelectTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim objCn As New Connection, objOld As Recordset
Dim iJudge() As Integer, iSelOne() As Integer
Dim iProRead() As Integer, iProFill() As Integer
Dim isSaved As Boolean
Private Sub cmbOld_Click()
Dim iTotal%, objTemp As New Recordset, m%, j%, i%
Dim sJ$, sSO$, sPR$, sPF$, vJ, vSO, vPR, vPF
If cmbOld.ListIndex > 0 Then
'清除窗体中原有显示数据
For i = 0 To 3
txtSum(i) = "": txtScore(i) = ""
Next
For i = 0 To 5
txtDivSum(i) = ""
Next
'访问数据库,获得选中试卷的试题数据
If objCn.State = adStateClosed Then objCn.Open
With objTemp
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select * from " & cmbOld
If .RecordCount > 0 Then
.MoveFirst
While Not .EOF
Select Case .Fields("题型")
Case "判断题"
txtScore(0) = Trim(Str(.Fields("分数")))
txtSum(0) = Trim(Str(Val(txtSum(0)) + 1))
sJ = sJ & "," & Trim(Str(.Fields("编号")))
Case "选择题"
txtScore(1) = Trim(Str(.Fields("分数")))
txtSum(1) = Trim(Str(Val(txtSum(1)) + 1))
sSO = sSO & "," & Trim(Str(.Fields("编号")))
Case "程序阅读"
txtScore(2) = Trim(Str(.Fields("分数")))
'计算选中题的分题干数
objProRead.MoveFirst
objProRead.Find "编号=" & Str(.Fields("编号"))
m = 0
For j = 1 To 3
If objProRead.Fields("分题干" & Trim(Str(j))) <> "" Then _
m = m + 1
Next
txtDivSum(m - 1) = Trim(Str(Val(txtDivSum(m - 1)) + 1))
sPR = sPR & "," & Trim(Str(.Fields("编号")))
Case "程序填空"
txtScore(3) = Trim(Str(.Fields("分数")))
'计算选中题的填空数
objProFill.MoveFirst
objProFill.Find "编号=" & Str(.Fields("编号"))
m = 0
For j = 1 To 4
If objProFill.Fields("空" & Chr(j + 96)) <> "" Then _
m = m + 1
Next
txtDivSum(m + 1) = Trim(Str(Val(txtDivSum(m + 1)) + 1))
sPF = sPF & "," & Trim(Str(.Fields("编号")))
End Select
.MoveNext
Wend
'显示小题数
txtSum(2) = Trim(Str(Val(txtDivSum(0)) + Val(txtDivSum(1)) * 2 _
+ Val(txtDivSum(2)) * 3))
txtSum(3) = Trim(Str(Val(txtDivSum(3)) * 2 + Val(txtDivSum(4)) * 3 _
+ Val(txtDivSum(5)) * 4))
txtTotalScore = Trim(Str(Val(txtScores(0)) + Val(txtScores(1)) _
+ Val(txtScores(2)) + Val(txtScores(3))))
'获得试题数据
vJ = Split(sJ, ",")
vSO = Split(sSO, ",")
vPR = Split(sPR, ",")
vPF = Split(sPF, ",")
ReDim iJudge(UBound(vJ))
For i = 0 To UBound(vJ)
iJudge(i) = Val(vJ(i))
Next
ReDim iSelOne(UBound(vSO))
For i = 0 To UBound(vSO)
iSelOne(i) = Val(vSO(i))
Next
ReDim iProRead(UBound(vPR))
For i = 0 To UBound(vPR)
iProRead(i) = Val(vPR(i))
Next
ReDim iProFill(UBound(vPF))
For i = 0 To UBound(vPF)
iProFill(i) = Val(vPF(i))
Next
End If
.Close
End With
Set objTemp = Nothing
End If
End Sub
Private Sub cmdAuto_Click()
Dim i%, j%, s%, n%, m%, iPRS%(3), iPFS%(3)
'检验试题设置是否正确
If Check_Seting() = False Then Exit Sub
'根据小题数量定义数组大小
ReDim iJudge(Val(txtSum(0)))
ReDim iSelOne(Val(txtSum(1)))
ReDim iProRead(Val(txtSum(2)))
ReDim iProFill(Val(txtSum(3)))
'随机产生判断题
For i = 1 To Val(txtSum(0))
With objJudge
n = Int(Rnd * .RecordCount + 1) '随机产生一个记录号
'获得试题编号
.MoveFirst
.Move n - 1, adBookmarkFirst
n = .Fields("编号")
'检查试题编号是否重复
For j = 1 To i - 1
If iJudge(j) = n Then Exit For
Next
If j < i Then
i = i - 1 '重新抽取题号
Else
iJudge(i) = n '保存未重复的题号
End If
End With
Next
'随机产生选择题
For i = 1 To Val(txtSum(1))
With objSelOne
n = Int(Rnd * .RecordCount + 1) '随机产生一个记录号
'获得试题编号
.MoveFirst
.Move n - 1, adBookmarkFirst
n = .Fields("编号")
'检查试题编号是否重复
For j = 1 To i - 1
If iSelOne(j) = n Then Exit For
Next
If j < i Then
i = i - 1 '重新抽取题号
Else
iSelOne(i) = n '保存未重复的题号
End If
End With
Next
'随机产生程序阅读题
s = 1
For i = 1 To Val(txtSum(2))
With objProRead
n = Int(Rnd * .RecordCount + 1) '随机产生一个记录号
'获得试题编号
.MoveFirst
.Move n - 1, adBookmarkFirst
n = .Fields("编号")
'检查试题编号是否重复
For j = 1 To i - 1
If iProRead(j) = n Then Exit For
Next
If j < i Then
i = i - 1 '重新抽取题号
Else
'计算选中题的分题干数
m = 0
For j = 1 To 3
If .Fields("分题干" & Trim(Str(j))) <> "" Then m = m + 1
Next
If iPRS(m) < Val(txtDivSum(m - 1)) Then
iProRead(s) = n '保存未重复的题号
s = s + 1
iPRS(m) = iPRS(m) + 1
i = i + m - 1
Else
i = i - 1 '重新抽取题号
End If
End If
End With
Next
'随机产生程序阅读题
s = 1
For i = 1 To Val(txtSum(3))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -