?? stud1.bas
字號:
Attribute VB_Name = "Module1"
'標準模塊Module1(Stud1.bas)
Option Explicit
Public gstrUser As String '全局變量存用戶名
Public gblnPurview As Boolean '全局變量存用戶權限
Public pubCnn As New ADODB.Connection '全局連接對象供各模塊使用
'建立連接
Public Sub CreateConnection()
pubCnn.CursorLocation = adUseClient
pubCnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stud97.mdb"
End Sub
'填充班級組合框。參數為組合框對象變量
Public Sub AddClassItem(cboX As ComboBox)
Dim rsTmp As New ADODB.Recordset '臨時記錄集
rsTmp.Open "SELECT DISTINCT 班級 FROM 學籍 " & _
" WHERE 班級<>NULL AND 班級<>''", _
pubCnn, adOpenStatic, adLockOptimistic
'在組合框中添加班級
cboX.Clear
Do Until rsTmp.EOF
cboX.AddItem rsTmp("班級")
rsTmp.MoveNext
Loop
Set rsTmp = Nothing
End Sub
Public Sub FocusBack(txtX As TextBox)
With txtX
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
End Sub
Public Sub NewClassItem(cboX As ComboBox) '參數為組合框對象變量
Dim i As Integer
Dim blnOld As Boolean '班級名稱存在標志
Dim sNew As String
blnOld = False
sNew = Trim$(cboX.Text) '取用戶在組合框輸入的班級名稱
For i = 0 To cboX.ListCount - 1
'若列表中已有該班級,設置標志,退出循環
If cboX.List(i) = sNew Or sNew = "" Then
blnOld = True
Exit For
End If
Next
If blnOld = False Then '若列表中無該班級名稱,添加
cboX.AddItem sNew
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -