⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stud1.bas

📁 大学数据库原理的课程设计
💻 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 + -