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

📄 ex27_frm1.frm

📁 一个很好的教务管理小程序
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "ex27_frm1.frx":24EC
            Key             =   "delete"
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "ex27_frm1.frx":2A50
            Key             =   "Find"
         EndProperty
         BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "ex27_frm1.frx":31C4
            Key             =   "Exit"
         EndProperty
      EndProperty
   End
   Begin VB.Label Label11 
      AutoSize        =   -1  'True
      Caption         =   "平均"
      Height          =   180
      Left            =   3720
      TabIndex        =   22
      Top             =   4560
      Width           =   360
   End
   Begin VB.Label Label10 
      AutoSize        =   -1  'True
      Caption         =   "语文"
      Height          =   180
      Left            =   3720
      TabIndex        =   10
      Top             =   3840
      Width           =   360
   End
   Begin VB.Label Label9 
      AutoSize        =   -1  'True
      Caption         =   "外语"
      Height          =   180
      Left            =   3720
      TabIndex        =   9
      Top             =   3240
      Width           =   360
   End
   Begin VB.Label Label8 
      AutoSize        =   -1  'True
      Caption         =   "化学"
      Height          =   180
      Left            =   3720
      TabIndex        =   8
      Top             =   2520
      Width           =   360
   End
   Begin VB.Label Label7 
      AutoSize        =   -1  'True
      Caption         =   "物理"
      Height          =   180
      Left            =   3720
      TabIndex        =   7
      Top             =   1680
      Width           =   360
   End
   Begin VB.Label Label6 
      AutoSize        =   -1  'True
      Caption         =   "数学"
      Height          =   180
      Left            =   3720
      TabIndex        =   6
      Top             =   960
      Width           =   360
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      Caption         =   "性别"
      Height          =   180
      Left            =   720
      TabIndex        =   5
      Top             =   3600
      Width           =   360
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "系别"
      Height          =   180
      Left            =   720
      TabIndex        =   4
      Top             =   2880
      Width           =   360
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "姓名"
      Height          =   180
      Left            =   720
      TabIndex        =   3
      Top             =   2040
      Width           =   360
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "学号"
      Height          =   180
      Left            =   720
      TabIndex        =   2
      Top             =   1440
      Width           =   360
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "编号"
      Height          =   180
      Left            =   720
      TabIndex        =   1
      Top             =   840
      Width           =   360
   End
End
Attribute VB_Name = "ex27_frm1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'保证只选中一个复选框
Private Sub check1_click()
    Check2.Value = 1 - Check1.Value
End Sub

Private Sub check2_click()
    Check1.Value = 1 - Check2.Value
End Sub

Private Sub Data1_Reposition()
    
    '求出某个学生的平均分数
    Text10.Text = _
    Format$((Val(Text5.Text) + Val(Text6.Text) + Val(Text7.Text) + Val(Text8.Text) + Val(Text9.Text)) / 5)
    '如果数据库里没有任何记录,使一些按钮无效
If Data1.Recordset.RecordCount = 0 Then
    
    Toolbar1.Buttons("first").Enabled = False
    Toolbar1.Buttons("previous").Enabled = False
    Toolbar1.Buttons("next").Enabled = False
    Toolbar1.Buttons("last").Enabled = False
    Toolbar1.Buttons("delete").Enabled = False
    Toolbar1.Buttons("find").Enabled = False
Else
    '在添加记录后,是按钮有效
    Toolbar1.Buttons("First").Enabled = True
    Toolbar1.Buttons("previous").Enabled = True
    Toolbar1.Buttons("next").Enabled = True
    Toolbar1.Buttons("last").Enabled = True
    Toolbar1.Buttons("delete").Enabled = True
    Toolbar1.Buttons("find").Enabled = True
End If

End Sub

Private Sub Data1_Validate(Action As Integer, Save As Integer)
Dim msg
Select Case Action
    '如果进行了操作方法
    'MoveFirst
    'MovePrevious
    'MoveNext
    'MoveLast
    'AddNew
    'end
    '这些操作就会产生 Data1_Validate()事件
    Case 1, 2, 3, 4, 5, 11
    If Save Then
        msg = MsgBox("数据需要更新?", vbYesNo)
        If msg = vbNo Then
        '如果不需要更新数据库,让save参数置0
            Save = 0
        End If
    End If
    '恢复删除记录按钮
    Toolbar1.Buttons("delete").Enabled = True
End Select
End Sub

Private Sub Form_Activate()
Data1.DatabaseName = App.Path + "\教务.mdb"
    If Data1.Recordset.RecordCount = 0 Then
        MsgBox "当前数据库内没有任何记录,请首先添加记录"
        Data1.Recordset.AddNew
    Else
        Data1.Recordset.MoveLast
    End If
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    Dim news, old
    Select Case Button.Key
        Case "First"
            Data1.Recordset.MoveFirst
        Case "previous"
            Data1.Recordset.MovePrevious
            If Data1.Recordset.BOF Then
            Data1.Recordset.MoveLast
                  
            End If
        Case "next"
            Data1.Recordset.MoveNext
            If Data1.Recordset.EOF Then
            Data1.Recordset.MoveFirst
            End If
        Case "last"
            Data1.Recordset.MoveLast
        Case "add"
            Data1.Recordset.AddNew
            Toolbar1.Buttons("delete").Enabled = False
            Text1.SetFocus
        Case "delete"
            '设置一个错误陷阱
            On Error Resume Next
            news = MsgBox("一定要删除该记录吗?", vbYesNo)
            If news = vbYes Then
                Data1.Recordset.Delete
                Data1.Recordset.MoveNext
                If Data1.Recordset.EOF Then
                Data1.Recordset.MoveLast
            End If
            End If
        Case "find"
            Unload Me
            frmex27_frm2.Show
            
        Case "exit"
            MsgBox "欢迎使用VB数据库应用程序,感谢各位用户的支持和厚爱!"
            old = MsgBox("要退出该用于程序吗?", vbYesNo)
            If old = vbYes Then
                End
            End If
    End Select
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -