?? frmselecttest.frm
字號:
Top = 2640
Width = 495
End
Begin VB.Label Label21
BackStyle = 0 'Transparent
Caption = "4、填空題"
Height = 255
Left = 360
TabIndex = 31
Top = 2640
Width = 855
End
Begin VB.Label Label20
BackStyle = 0 'Transparent
Caption = "分"
Height = 255
Left = 6120
TabIndex = 28
Top = 2175
Width = 375
End
Begin VB.Label Label19
BackStyle = 0 'Transparent
Caption = "共"
Height = 255
Left = 5040
TabIndex = 26
Top = 2175
Width = 375
End
Begin VB.Label Label18
BackStyle = 0 'Transparent
Caption = "分"
Height = 255
Left = 4200
TabIndex = 25
Top = 2175
Width = 375
End
Begin VB.Label Label17
BackStyle = 0 'Transparent
Caption = "每題"
Height = 255
Left = 2880
TabIndex = 23
Top = 2175
Width = 495
End
Begin VB.Label Label16
BackStyle = 0 'Transparent
Caption = "小題"
Height = 255
Left = 1920
TabIndex = 22
Top = 2175
Width = 495
End
Begin VB.Label Label15
BackStyle = 0 'Transparent
Caption = "3、多選題"
Height = 255
Left = 360
TabIndex = 20
Top = 2175
Width = 855
End
Begin VB.Label Label14
BackStyle = 0 'Transparent
Caption = "分"
Height = 255
Left = 6120
TabIndex = 19
Top = 1665
Width = 375
End
Begin VB.Label Label13
BackStyle = 0 'Transparent
Caption = "共"
Height = 255
Left = 5040
TabIndex = 17
Top = 1665
Width = 375
End
Begin VB.Label Label12
BackStyle = 0 'Transparent
Caption = "分"
Height = 255
Left = 4200
TabIndex = 16
Top = 1665
Width = 375
End
Begin VB.Label Label11
BackStyle = 0 'Transparent
Caption = "每題"
Height = 255
Left = 2880
TabIndex = 14
Top = 1665
Width = 495
End
Begin VB.Label Label10
BackStyle = 0 'Transparent
Caption = "小題"
Height = 255
Left = 1920
TabIndex = 13
Top = 1665
Width = 495
End
Begin VB.Label Label9
BackStyle = 0 'Transparent
Caption = "2、單選題"
Height = 255
Left = 360
TabIndex = 11
Top = 1665
Width = 855
End
Begin VB.Label Label8
BackStyle = 0 'Transparent
Caption = "分"
Height = 255
Left = 6120
TabIndex = 10
Top = 1125
Width = 375
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "共"
Height = 255
Left = 5040
TabIndex = 8
Top = 1125
Width = 375
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "分"
Height = 255
Left = 4200
TabIndex = 7
Top = 1125
Width = 375
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "每題"
Height = 255
Left = 2880
TabIndex = 5
Top = 1125
Width = 495
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "小題"
Height = 255
Left = 1920
TabIndex = 4
Top = 1125
Width = 495
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "1、判斷題"
Height = 255
Left = 360
TabIndex = 2
Top = 1125
Width = 855
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "試卷總分"
Height = 255
Left = 3960
TabIndex = 1
Top = 480
Width = 735
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "試卷名稱"
Height = 255
Left = 360
TabIndex = 0
Top = 480
Width = 855
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 iselmany() As Integer, ifill() As Integer, ianswer() As Integer
Dim issaved As Boolean
'判斷題數據訪問屬性過程
Public Property Get judge() As Variant
judge = ijudge
End Property
Public Property Let judge(inew As Variant)
ijudge = inew
End Property
'單選題數據訪問屬性過程
Public Property Get selone() As Variant
selone = iselone
End Property
Public Property Let selone(inew As Variant)
iselone = inew
End Property
'多選題數據訪問屬性過程
Public Property Get selmany() As Variant
selmany = iselmany
End Property
Public Property Let selmany(inew As Variant)
iselmany = inew
End Property
'填空題數據訪問屬性過程
Public Property Get fill() As Variant
fill = ifill
End Property
Public Property Let fill(inew As Variant)
ifill = inew
End Property
'問答題數據訪問屬性過程
Public Property Get answer() As Variant
answer = ianswer
End Property
Public Property Let answer(inew As Variant)
ianswer = inew
End Property
Private Sub Form_Load()
'建立數據庫連接
Set objCn = New Connection '定義并實例化連接對象
With objCn '建立連接
.Provider = "SQLOLEDB"
.ConnectionString = "user id=sa;data source=(local);" & _
"initial catalog=自測考試"
.Open
End With
'訪問數據庫獲得判斷題數據
Set objJudge = New Recordset
With objJudge
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select * from 判斷題"
Set .ActiveConnection = Nothing
End With
'訪問數據庫獲得單選題數據
Set objSelOne = New Recordset
With objSelOne
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select * from 單項選擇題"
Set .ActiveConnection = Nothing
End With
'訪問數據庫獲得多項選題數據
Set objselmany = New Recordset
With objselmany
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select * from 多項選擇題"
Set .ActiveConnection = Nothing
End With
'訪問數據庫獲得填空題數據
Set objFill = New Recordset
With objFill
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select * from 填空題"
Set .ActiveConnection = Nothing
End With
'訪問數據庫獲得問答題數據
Set objanswer = New Recordset
With objanswer
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select * from 問答題"
Set .ActiveConnection = Nothing
End With
'訪問數據庫獲得歷屆試題數據
Set objold = New Recordset
With objold
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select * from 歷屆考題"
Set .ActiveConnection = Nothing
Cmbold.AddItem ""
If .RecordCount > 0 Then
.MoveFirst
While Not .EOF
Cmbold.AddItem .Fields("表名")
.MoveNext
Wend
End If
End With
objCn.Close
End Sub
Private Sub cmdclear_Click()
Dim i%
txtname = ""
issaved = False
Cmdsave.Enabled = False
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set objCn = Nothing: Set objold = Nothing
Set objJudge = Nothing: Set objSelOne = Nothing
Set objselmany = Nothing: Set objFill = Nothing
Set objanswer = Nothing
End Sub
Private Sub txtname_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "[0-9]" Then
KeyAscii = 0
End If
End Sub
Private Sub txtscore_Change(Index As Integer)
If Val(txtsum(Index)) <> 0 Then
txtscores(Index) = Val(txtsum(Index)) * Val(txtscore(Index))
End If
End Sub
Private Sub txtsum_Change(Index As Integer)
If Val(txtscore(Index)) <> 0 Then
txtscores(Index) = Val(txtsum(Index)) * Val(txtscore(Index))
End If
End Sub
'檢查小題分數值輸入
Private Sub txtscore_KeyPress(Index As Integer, KeyAscii As Integer)
If Not (Chr(KeyAscii) Like "[0-9]" Or KeyAscii = vbKeyBack) Then
KeyAscii = 0
End If
End Sub
'檢查小題數量輸入
Private Sub txtsum_KeyPress(Index As Integer, KeyAscii As Integer)
If Not (Chr(KeyAscii) Like "[0-9]" Or KeyAscii = vbKeyBack) Then
KeyAscii = 0
End If
End Sub
'檢查總分輸入
Private Sub txttotalscore_KeyPress(KeyAscii As Integer)
If Not (Chr(KeyAscii) Like "[0-9]" Or KeyAscii = vbKeyBack) Then
KeyAscii = 0
End If
End Sub
'Private Sub txtname_Change()
'Dim m$
'm = Left(selecttest.txtName.Text, 1)
'If m Like "[0-9]" Then
'KeyAscii = 0
'End If
'End Sub
Private Function Check_Seting() As Boolean
Dim i%, s%
Check_Seting = False
'檢查是否正確的設置了各類型題的小題數和分數
For i = 0 To 4
If Val(txtsum(i)) = 0 Then
MsgBox "請設置正確的小題數量!", vbCritical, Me.Caption
txtsum(i).SetFocus
Exit Function
ElseIf Val(txtscore(i)) = 0 Then
MsgBox "請設置正確的小題分數!", vbCritical, Me.Caption
txtscore(i).SetFocus
Exit Function
End If
s = s + Val(txtscores(i))
Next
'檢查小題分數合計與總分是否一致
If Val(txttotalscore) <> Val(s) Then
MsgBox "小題分數合計與試卷總分不一致!", vbCritical, Me.Caption
Exit Function
End If
'檢驗填空題設置是否正確
If Val(txtdiv(0)) + Val(txtdiv(1)) * 2 + Val(txtdiv(2)) * 3 + Val(txtdiv(3)) * 4 <> Val(txtsum(4)) Then
MsgBox "填空題設置不正確!", vbCritical, Me.Caption
txtdiv(0).SetFocus
Exit Function
End If
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -