5.多選題
多選題有 10 個核取方塊讓學生選取,分別為 s1 s2 ...s9 sa。另有 10 個核取方塊 a1 a2 ..aa 是隱藏的,看不到,用來儲存答案的。
黑色:程式碼 藍色:說明
Dim sno, pwr As Integer
宣告 sno, pwr 為整數變數,pwr是加權值,見 加權計分
Dim ermsg As String
宣告 ermsg 為字串變數,用來記錄核取方塊的號碼
Private Sub CommandButton1_Click() 按下按鈕後的程式
If tea = 1 Then
If Slide2.modify <> True Then Label1 = itmno
CommandButton1.Caption = Slide2.submit.Caption 從試卷設定頁取得按鈕符號
If anset = 1 Then 如果 anset = 1 ,也就是要設定答案
a1 = s1 把 s1 的值寫入 a1
a2 = s2
a3 = s3
a4 = s4
a5 = s5
a6 = s6
a7 = s7
a8 = s8
a9 = s9
aa = sa
If s1.Value = True Then ermsg = ermsg & " 1"
如果 s1的值是 True (被打勾 v 的意思),把 1 寫入 ermsg
If s2.Value = True Then ermsg = ermsg & " 2"
If s3.Value = True Then ermsg = ermsg & " 3"
If s4.Value = True Then ermsg = ermsg & " 4"
If s5.Value = True Then ermsg = ermsg & " 5"
If s6.Value = True Then ermsg = ermsg & " 6"
If s7.Value = True Then ermsg = ermsg & " 7"
If s8.Value = True Then ermsg = ermsg & " 8"
If s9.Value = True Then ermsg = ermsg & " 9"
If sa.Value = True Then ermsg = ermsg & " 10"
MsgBox seta & ermsg 訊息盒顯示:設定答案為 ermsg
Else 否則,也就是沒有要設定答案
End If
nex
s1.Value = False 清空核取方塊的 v
s2.Value = False
s3.Value = False
s4.Value = False
s5.Value = False
s6.Value = False
s7.Value = False
s8.Value = False
s9.Value = False
sa.Value = False
s1.BackColor = &HFFFFFF 回復預設的顏色
s2.BackColor = &HFFFFFF
s3.BackColor = &HFFFFFF
s4.BackColor = &HFFFFFF
s5.BackColor = &HFFFFFF
s6.BackColor = &HFFFFFF
s7.BackColor = &HFFFFFF
s8.BackColor = &HFFFFFF
s9.BackColor = &HFFFFFF
sa.BackColor = &HFFFFFF
Label1.BackColor = &HFFFFFF
Else 否則,也就是 tea≠1,是學生按的
If itmno <> Label1 Then
MsgBox eropstn
fist
Exit Sub
End If
If s1.Value = False Then s1 .Value = False 表示學生沒有勾選 v 這個選項
If s2.Value = False Then
If s3.Value = False Then
If s4.Value = False Then
If s5.Value = False Then
If s6.Value = False Then
If s7.Value = False Then
If s8.Value = False Then
If s9.Value = False Then
If sa.Value = False Then
MsgBox "尚未作答 Select you'r answer"
Exit Sub
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
pwr = Label2 把題號右邊的 Label2 的值寫入 pwr
If s1 <> a1 Then 如果 s1≠a1 ,表示學生在這個選項上是錯的
ermsg = ermsg & " 1" 把 1寫入ermsg,數字前的空格也會寫進去
s1.BackColor = &HC0C0FF s1 的背景顏色改成紅色
Else 否則,也就是答對
s1.BackColor = &HFFFFFF s1 的背景顏色改成白色
End If
If s2 <> a2 Then
ermsg = ermsg & " 2"
s2.BackColor = &HC0C0FF
Else
s2.BackColor = &HFFFFFF
End If
If s3 <> a3 Then
ermsg = ermsg & " 3"
s3.BackColor = &HC0C0FF
Else
s3.BackColor = &HFFFFFF
End If
If s4 <> a4 Then
ermsg = ermsg & " 4"
s4.BackColor = &HC0C0FF
Else
s4.BackColor = &HFFFFFF
End If
If s5 <> a5 Then
ermsg = ermsg & " 5"
s5.BackColor = &HC0C0FF
Else
s5.BackColor = &HFFFFFF
End If
If s6 <> a6 Then
ermsg = ermsg & " 6"
s6.BackColor = &HC0C0FF
Else
s6.BackColor = &HFFFFFF
End If
If s7 <> a7 Then
ermsg = ermsg & " 7"
s7.BackColor = &HC0C0FF
Else
s7.BackColor = &HFFFFFF
End If
If s8 <> a8 Then
ermsg = ermsg & " 8"
s8.BackColor = &HC0C0FF
Else
s8.BackColor = &HFFFFFF
End If
If s9 <> a9 Then
ermsg = ermsg & " 9"
s9.BackColor = &HC0C0FF
Else
s9.BackColor = &HFFFFFF
End If
If sa <> aa Then
ermsg = ermsg & " 10"
sa.BackColor = &HC0C0FF
Else
sa.BackColor = &HFFFFFF
End If
If ermsg = "" Then 如果 ermsg 是空的,也就是沒有錯誤
If sno = flow Then
MsgBox eropstn
nex
Exit Sub
End If
rt = rt + 1 答對數+1
den = den + pwr - 1 分母=分母+pwr - 1
num = num + pwr - 1 分子=分子+pwr - 1
Label1.BackColor = &HFFFFFF 題號背景顏色設為白色
MsgBox rtstn 訊息盒顯示:答對時的回饋
sno = flow
nex
Else 否則,也就是有錯誤
If sno = flow Then
MsgBox mg & " : " & ermsg & " , " & eropstn
nex
Exit Sub
End If
er = er + 1 答對數+1
den = den + pwr - 1 分母=分母+pwr - 1
erstring = erstring & " " & itmno 把題號寫入erstring
Label1.BackColor = &HC0C0FF 題號背景設成紅色
MsgBox mg & " : " & ermsg 訊息盒顯示:mg(答錯的項次是):ermsg
sno = flow
nex
End If
End If
itmno = itmno + 1
ermsg = "" 清空ermsg
Label3 = "E-test6"
Label3.Width = 78
Label3.Top = 5
Label3.Left = 642
Label3.Height = 32
End Sub
Private Sub Label2_Click() Label2是題號右邊的數字,用來設定加權值
If tea = 1 Then 教師才能設定
If pwr = 0 Then pwr = 1
pwr = pwr + 1
If pwr = 5 Then pwr = 1
Label2 = pwr
Else
Exit Sub
End If
End Sub