📄 test.frm
字号:
Left = 4920
TabIndex = 19
Top = 4080
Width = 1095
End
Begin VB.Frame Frame4
Caption = "选项"
Height = 3015
Left = 120
TabIndex = 10
Top = 960
Width = 7935
Begin VB.OptionButton Option4
Height = 255
Left = 360
TabIndex = 14
Top = 2400
Width = 375
End
Begin VB.OptionButton Option3
Height = 255
Left = 360
TabIndex = 13
Top = 1680
Width = 375
End
Begin VB.OptionButton Option2
Height = 255
Left = 360
TabIndex = 12
Top = 1080
Width = 375
End
Begin VB.OptionButton Option1
Height = 255
Left = 360
TabIndex = 11
Top = 480
Width = 375
End
Begin VB.Label Label8
Caption = "Label8"
Height = 375
Left = 1440
TabIndex = 18
Top = 2400
Width = 2415
End
Begin VB.Label Label7
Caption = "Label7"
Height = 375
Left = 1440
TabIndex = 17
Top = 1680
Width = 2295
End
Begin VB.Label Label6
Caption = "Label6"
Height = 375
Left = 1440
TabIndex = 16
Top = 1080
Width = 2775
End
Begin VB.Label Label5
Caption = "Label5"
Height = 375
Left = 1440
TabIndex = 15
Top = 480
Width = 3135
End
End
Begin VB.TextBox Text1
Height = 375
Left = 1080
TabIndex = 9
Text = "Text1"
Top = 360
Width = 6855
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "题目"
Height = 180
Left = 360
TabIndex = 8
Top = 480
Width = 360
End
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 615
Left = 5640
TabIndex = 2
Top = 4920
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "提交"
Height = 615
Left = 3720
TabIndex = 1
Top = 4920
Width = 1215
End
End
End
Attribute VB_Name = "test"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim c(1 To 10) As TextBox
Dim b(1 To 10) As TextBox
Dim mrc As ADODB.Recordset
Dim mrc2 As ADODB.Recordset
Dim i As Integer
Dim l As Integer
Dim scor As Integer
Dim j As Integer
Dim n As Integer
Private Sub Command1_Click()
On Error Resume Next
Dim mrc As ADODB.Recordset
txtsql = "select * from 学生情况 where 班级='" & _
Trim$(student.Text1.Text) & "'" & " and 学号='" & Trim$(student.Text2.Text) + "'" & " and 姓名 = '" & Trim(student.Text3.Text) & "'"
Set mrc = exesql(txtsql)
Dim strdate As String
i = 0
l = 0
If MsgBox("你真的要提交吗?", vbYesNo) = vbYes Then
For m = 1 To 10
If Text3(i).Text = Text4(l).Text Then
scor = scor + 5
i = i + 1
l = l + 1
End If
Next
MsgBox "你的分数为:" & scor & "分"
Else
End If
Frame3.Enabled = False
mrc.AddNew
mrc.Fields("班级") = student.Text1
mrc.Fields("学号") = student.Text2
mrc.Fields("姓名") = student.Text3
mrc.Fields("登录时间") = CStr(Date)
mrc.Fields("成绩") = scor
mrc.Update
End Sub
Private Sub Command2_Click()
If MsgBox("你真的要退出吗?", vbYesNo) = vbYes Then
Unload Me
Else
End If
End Sub
Private Sub Command3_Click()
Command4.Enabled = True
If n < 4 Then
n = 4
ElseIf n >= 12 Then
n = 12
Else
n = n + 1
End If
txtsql1 = "select * from 试卷 where 试卷号 = '" & Text2 & "'"
Set mrc2 = exesql(txtsql1)
txtsql = "select * from 选择题 where 题号 = '" & mrc2.Fields(n) & "'"
Set mrc = exesql(txtsql)
Label5.Caption = mrc.Fields("选项1")
Label6.Caption = mrc.Fields("选项2")
Label7.Caption = mrc.Fields("选项3")
Label8.Caption = mrc.Fields("选项4")
Text1.Text = mrc.Fields("题目")
If l >= 10 Then
l = 10
Command3.Enabled = False
Else
If Option1.Value = True Then
Text4(l).Text = "A"
ElseIf Option2.Value = True Then
Text4(l).Text = "B"
ElseIf Option3.Value = True Then
Text4(l).Text = "C"
ElseIf Option4.Value = True Then
Text4(l).Text = "D"
Else
Text4(l).Text = ""
End If
l = l + 1
End If
Option1.Value = False
Option2.Value = False
Option3.Value = False
Option4.Value = False
End Sub
Private Sub Command4_Click()
On Error Resume Next
Command3.Enabled = True
If n > 12 Then
n = 12
ElseIf n < 3 Then
n = 3
Else
txtsql1 = "select * from 试卷 where 试卷号 = '" & Text2 & "'"
Set mrc2 = exesql(txtsql1)
txtsql = "select * from 选择题 where 题号 = '" & mrc2.Fields(n) & "'"
Set mrc = exesql(txtsql)
Label5.Caption = mrc.Fields("选项1")
Label6.Caption = mrc.Fields("选项2")
Label7.Caption = mrc.Fields("选项3")
Label8.Caption = mrc.Fields("选项4")
Text1.Text = mrc.Fields("题目")
n = n - 1
End If
If l <= 0 Then
l = 0
Command4.Enabled = False
Else
If Option1.Value = True Then
Text4(l).Text = "A"
ElseIf Option2.Value = True Then
Text4(l).Text = "B"
ElseIf Option3.Value = True Then
Text4(l).Text = "C"
ElseIf Option4.Value = True Then
Text4(l).Text = "D"
Else
Text4(l).Text = ""
End If
l = l - 1
End If
Option1.Value = False
Option2.Value = False
Option3.Value = False
Option4.Value = False
End Sub
Private Sub Command5_Click()
find.Show
End Sub
Private Sub Form_Load()
n = 3
l = 1
Text2.Text = GetSetting("试卷生成和评分系统", "系统设置", "Btime", shiti.Text1.Text)
Call subtest
' Select Case i
' Case 1
' txtsql = "select 答案 from 选择题 where 题号 = '" & mrc2.Fields(4)
' Set mrc = exesql(txtsql)
' i = 2
' c(1) = mrc.Fields("答案")
' Case 2
' txtsql = "select 答案 from 选择题 where 题号 = '" & mrc2.Fields(5)
' End Select
Label1.Caption = 30
Label3.Caption = 60
Frame3.Enabled = True
limite.Option4.Value = GetSetting("试卷生成和评分系统", "系统设置", "test1", limite.Option4.Value)
limite.Option5.Value = GetSetting("试卷生成和评分系统", "系统设置", "test2", limite.Option5.Value)
If limite.Option4 = True Then
Frame3.Enabled = False
Command1.Enabled = False
Command5.Enabled = True
Timer1.Enabled = False
Else
Frame3.Enabled = True
Command1.Enabled = True
Command5.Enabled = False
End If
Command4_Click
End Sub
Private Sub Form_Resize()
Frame1.Left = (Me.Width - Frame1.Width) / 2
Frame1.Top = (Me.Height - Frame1.Height) / 2
Frame2.Left = (Me.Width - Frame2.Width) / 2
Frame2.Top = (Me.Height - Frame1.Height) / 2 - Frame2.Height
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub Timer1_Timer()
Label3.Caption = Label3.Caption - 1
If Label3.Caption = 0 Then
Label1.Caption = Label1.Caption - 1
If Label1.Caption < 0 Then
MsgBox "时间到了,请停止做题"
Frame3.Enabled = False
End If
Label3.Caption = 60
End If
End Sub
Public Sub subtest()
j = 3
i = 0
On Error Resume Next
txtsql1 = "select * from 试卷 where 试卷号 = '" & Text2 & "'"
Set mrc2 = exesql(txtsql1)
For k = 1 To 10
txtsql = "select 答案 from 选择题 where 题号 = '" & mrc2.Fields(j) & "'"
Set mrc = exesql(txtsql)
Text3(i).Text = mrc.Fields("答案")
j = j + 1
i = i + 1
Next k
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -