4.選擇題
黑色:程式碼 藍色:說明
Dim sno As Integer sno 是區域變數,每張題目投影片都有一個,各自獨立、互不影響
Private Sub CommandButton1_Click() 第1個按鈕的程式
If tea = 1 Then 如果 tea = 1,取得教師權限
CommandButton1.Caption = Slide2.ch1.Caption 將試卷設定頁的按鈕符號取過來
CommandButton2.Caption = Slide2.ch2.Caption
CommandButton3.Caption = Slide2.ch3.Caption
CommandButton4.Caption = Slide2.ch4.Caption
CommandButton5.Caption = Slide2.ch5.Caption (4個選項的那張投影片沒有CommandButton5,以下同)
If Slide2.modify <> True Then Label1 = itmno 如果沒有要修改答案,將 itmno 寫進題號
If anset = 1 Then 如果 anset = 1 ,要設定答案
ScrollBar1.Value = 1 設定ScrollBar1(隱藏的捲軸,用來儲存答案)的值為 1
MsgBox seta & CommandButton1.Caption 訊息盒顯示:設定答案為按鈕1的內容
Else 如果 anset ≠ 1 ,也就是沒有要設定答案
End If
nex 到下一頁
CommandButton1.BackColor = &H8000000F 按鈕顏色回復預設值
CommandButton2.BackColor = &H8000000F
CommandButton3.BackColor = &H8000000F
CommandButton4.BackColor = &H8000000F
CommandButton5.BackColor = &H8000000F
Label1.BackColor = &HFFFFFF 題號背景顏色回復預設值
Else 否則 也就是 tea≠1,是學生按的
CommandButton1.BackColor = &HC0C0FF 第1個按鈕顏色設為紅色
CommandButton2.BackColor = &H8000000F 其他按鈕顏色回復預設值
CommandButton3.BackColor = &H8000000F
CommandButton4.BackColor = &H8000000F
CommandButton5.BackColor = &H8000000F
If Label1 <> itmno Then 如果題號≠itmno
MsgBox eropstn 訊息盒顯示:錯誤的操作程序
fist 到首頁
Exit Sub
End If
If sno = flow Then
MsgBox eropstn
fist
Exit Sub
Else 否則,也就是 sno ≠ flow,表示操作程序沒有錯誤
If ScrollBar1.Value = 1 Then 如果 ScrollBar1 =1 ,也就是答對
rt = rt + 1
Label1.BackColor = &HFFFFFF 設題號背景顏色為白色
MsgBox rtstn 訊息盒顯示:答對的回饋
sno = flow
nex
Else 否則,也就是答錯
er = er + 1
erstring = erstring & " " & itmno
Label1.BackColor = &HC0C0FF 題號背景顏色變紅色
MsgBox erstn
sno = flow
nex
End If
End If
End If
itmno = itmno + 1 itmno+1
Label2 = "E-test6"
Label2.Width = 78
Label2.Top = 5
Label2.Left = 642
Label2.Height = 32
End Sub
Private Sub CommandButton2_Click() 第2個按鈕的程式,以下略
If tea = 1 Then
CommandButton1.Caption = Slide2.ch1.Caption
CommandButton2.Caption = Slide2.ch2.Caption
CommandButton3.Caption = Slide2.ch3.Caption
CommandButton4.Caption = Slide2.ch4.Caption
CommandButton5.Caption = Slide2.ch5.Caption
If Slide2.modify <> True Then Label1 = itmno
If anset = 1 Then
ScrollBar1.Value = 2
MsgBox seta & CommandButton2.Caption
Else
End If
nex
CommandButton1.BackColor = &H8000000F
CommandButton2.BackColor = &H8000000F
CommandButton3.BackColor = &H8000000F
CommandButton4.BackColor = &H8000000F
CommandButton5.BackColor = &H8000000F
Label1.BackColor = &HFFFFFF
Else
CommandButton2.BackColor = &HC0C0FF
CommandButton1.BackColor = &H8000000F
CommandButton3.BackColor = &H8000000F
CommandButton4.BackColor = &H8000000F
CommandButton5.BackColor = &H8000000F
If Label1 <> itmno Then
MsgBox eropstn
fist
Exit Sub
End If
If sno = flow Then
MsgBox eropstn
fist
Exit Sub
Else
If ScrollBar1.Value = 2 Then
rt = rt + 1
Label1.BackColor = &HFFFFFF
MsgBox rtstn
sno = flow
nex
Else
er = er + 1
erstring = erstring & " " & itmno
Label1.BackColor = &HC0C0FF
MsgBox erstn
sno = flow
nex
End If
End If
End If
itmno = itmno + 1
Label2 = "E-test6"
Label2.Width = 78
Label2.Top = 5
Label2.Left = 642
Label2.Height = 32
End Sub
Private Sub CommandButton3_Click()
If tea = 1 Then
CommandButton1.Caption = Slide2.ch1.Caption
CommandButton2.Caption = Slide2.ch2.Caption
CommandButton3.Caption = Slide2.ch3.Caption
CommandButton4.Caption = Slide2.ch4.Caption
CommandButton5.Caption = Slide2.ch5.Caption
If Slide2.modify <> True Then Label1 = itmno
If anset = 1 Then
ScrollBar1.Value = 3
MsgBox seta & CommandButton3.Caption
Else
End If
nex
CommandButton1.BackColor = &H8000000F
CommandButton2.BackColor = &H8000000F
CommandButton3.BackColor = &H8000000F
CommandButton4.BackColor = &H8000000F
CommandButton5.BackColor = &H8000000F
Label1.BackColor = &HFFFFFF
Else
CommandButton3.BackColor = &HC0C0FF
CommandButton1.BackColor = &H8000000F
CommandButton2.BackColor = &H8000000F
CommandButton4.BackColor = &H8000000F
CommandButton5.BackColor = &H8000000F
If Label1 <> itmno Then
MsgBox eropstn
fist
Exit Sub
End If
If sno = flow Then
MsgBox eropstn
fist
Exit Sub
Else
If ScrollBar1.Value = 3 Then
rt = rt + 1
Label1.BackColor = &HFFFFFF
MsgBox rtstn
sno = flow
nex
Else
er = er + 1
erstring = erstring & " " & itmno
Label1.BackColor = &HC0C0FF
MsgBox erstn
sno = flow
nex
End If
End If
End If
itmno = itmno + 1
Label2 = "E-test6"
Label2.Width = 78
Label2.Top = 5
Label2.Left = 642
Label2.Height = 32
End Sub
Private Sub CommandButton4_Click()
If tea = 1 Then
CommandButton1.Caption = Slide2.ch1.Caption
CommandButton2.Caption = Slide2.ch2.Caption
CommandButton3.Caption = Slide2.ch3.Caption
CommandButton4.Caption = Slide2.ch4.Caption
CommandButton5.Caption = Slide2.ch5.Caption
If Slide2.modify <> True Then Label1 = itmno
If anset = 1 Then
ScrollBar1.Value = 4
MsgBox seta & CommandButton4.Caption
Else
End If
nex
CommandButton1.BackColor = &H8000000F
CommandButton2.BackColor = &H8000000F
CommandButton3.BackColor = &H8000000F
CommandButton4.BackColor = &H8000000F
CommandButton5.BackColor = &H8000000F
Label1.BackColor = &HFFFFFF
Else
CommandButton4.BackColor = &HC0C0FF
CommandButton1.BackColor = &H8000000F
CommandButton3.BackColor = &H8000000F
CommandButton2.BackColor = &H8000000F
CommandButton5.BackColor = &H8000000F
If Label1 <> itmno Then
MsgBox eropstn
fist
Exit Sub
End If
If sno = flow Then
MsgBox eropstn
fist
Exit Sub
Else
If ScrollBar1.Value = 4 Then
rt = rt + 1
Label1.BackColor = &HFFFFFF
MsgBox rtstn
sno = flow
nex
Else
er = er + 1
erstring = erstring & " " & itmno
Label1.BackColor = &HC0C0FF
MsgBox erstn
sno = flow
nex
End If
End If
End If
itmno = itmno + 1
Label2 = "E-test6"
Label2.Width = 78
Label2.Top = 5
Label2.Left = 642
Label2.Height = 32
End Sub
Private Sub CommandButton5_Click()
If tea = 1 Then
CommandButton1.Caption = Slide2.ch1.Caption
CommandButton2.Caption = Slide2.ch2.Caption
CommandButton3.Caption = Slide2.ch3.Caption
CommandButton4.Caption = Slide2.ch4.Caption
CommandButton5.Caption = Slide2.ch5.Caption
If Slide2.modify <> True Then Label1 = itmno
If anset = 1 Then
ScrollBar1.Value = 5
MsgBox seta & CommandButton5.Caption
Else
End If
nex
CommandButton1.BackColor = &H8000000F
CommandButton2.BackColor = &H8000000F
CommandButton3.BackColor = &H8000000F
CommandButton4.BackColor = &H8000000F
CommandButton5.BackColor = &H8000000F
Label1.BackColor = &HFFFFFF
Else
CommandButton5.BackColor = &HC0C0FF
CommandButton1.BackColor = &H8000000F
CommandButton3.BackColor = &H8000000F
CommandButton2.BackColor = &H8000000F
CommandButton4.BackColor = &H8000000F
If Label1 <> itmno Then
MsgBox eropstn
fist
Exit Sub
End If
If sno = flow Then
MsgBox eropstn
fist
Exit Sub
Else
If ScrollBar1.Value = 5 Then
rt = rt + 1
Label1.BackColor = &HFFFFFF
MsgBox rtstn
sno = flow
nex
Else
er = er + 1
erstring = erstring & " " & itmno
Label1.BackColor = &HC0C0FF
MsgBox erstn
sno = flow
nex
End If
End If
End If
itmno = itmno + 1
Label2 = "E-test6"
Label2.Width = 78
Label2.Top = 5
Label2.Left = 642
Label2.Height = 32
End Sub