?? frmselectdotest.frm
字號(hào):
VERSION 5.00
Begin VB.Form SelectDoTest
BorderStyle = 1 'Fixed Single
Caption = "選擇本次考題"
ClientHeight = 1860
ClientLeft = 45
ClientTop = 330
ClientWidth = 4605
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 1860
ScaleWidth = 4605
Begin VB.CommandButton cmdOk
Caption = "確定"
Default = -1 'True
Height = 315
Left = 1440
TabIndex = 3
Top = 1110
Width = 795
End
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "退出"
Height = 315
Left = 2370
TabIndex = 2
Top = 1110
Width = 795
End
Begin VB.ComboBox cmbTest
Height = 300
Left = 1492
Style = 2 'Dropdown List
TabIndex = 1
Top = 435
Width = 2385
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "試卷名稱"
Height = 180
Left = 727
TabIndex = 0
Top = 495
Width = 720
End
End
Attribute VB_Name = "SelectDoTest"
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
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdOk_Click()
Dim strSQL$
'將選擇的考試題數(shù)據(jù)表數(shù)據(jù)復(fù)制道ThisTest數(shù)據(jù)表中
With objCn
strSQL = "Drop Table ThisTest"
.Execute strSQL
strSQL = "select 編號(hào),題型,分?jǐn)?shù) into ThisTest From " & cmbTest
.Execute strSQL
End With
MsgBox "試題選擇成功!", vbInformation, Me.Caption
End Sub
Private Sub Form_Load()
With objCn '建立數(shù)據(jù)庫聯(lián)接
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;PWD=123;Data Source=(local);" & _
"Initial Catalog=自測考試"
.Open
End With
'訪問數(shù)據(jù)庫獲得歷屆試題數(shù)據(jù)
Set objOld = New Recordset '實(shí)例化對(duì)象
With objOld
Set .ActiveConnection = objCn '建立數(shù)據(jù)庫連接
.CursorLocation = adUseClient '指定使用客戶端游標(biāo)
.CursorType = adOpenStatic '指定使用靜態(tài)游標(biāo)
.Open "SELECT * FROM 歷屆試題" '獲取歷屆試題數(shù)據(jù)
Set .ActiveConnection = Nothing '斷開數(shù)據(jù)庫連接
If .RecordCount > 0 Then
.MoveFirst
While Not .EOF
cmbTest.AddItem .Fields("表名")
.MoveNext
Wend
End If
cmbTest.ListIndex = 0
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
objCn.Close '關(guān)閉數(shù)據(jù)庫連接
Set objOld = Nothing
Set objCn = Nothing
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -