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

📄 form1.frm

📁 实现学生成绩管理一个很好的vb实例可用作课程设计
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomctl.ocx"
Begin VB.Form frmMain 
   Caption         =   "成绩管理"
   ClientHeight    =   6225
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8685
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   6225
   ScaleWidth      =   8685
   StartUpPosition =   2  '屏幕中心
   Begin MSComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   615
      Left            =   0
      TabIndex        =   2
      Top             =   0
      Width           =   8685
      _ExtentX        =   15319
      _ExtentY        =   1085
      ButtonWidth     =   1455
      ButtonHeight    =   926
      Appearance      =   1
      ImageList       =   "ImageList1"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   7
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "添加"
            Key             =   "Append"
            ImageKey        =   "Append"
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "查询"
            Key             =   "Query"
            ImageKey        =   "Query"
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "删除"
            Key             =   "Delete"
            ImageKey        =   "Delete"
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "图表"
            Key             =   "Chart"
            ImageKey        =   "Chart"
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "更改密码"
            Key             =   "Password"
            ImageKey        =   "Password"
         EndProperty
         BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "退出"
            Key             =   "Exit"
            ImageKey        =   "Exit"
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   8040
      Top             =   5640
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   15
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   7
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":014A
            Key             =   "Append"
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0510
            Key             =   "Exit"
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":066A
            Key             =   "Password"
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0984
            Key             =   "Delete"
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0D56
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":111C
            Key             =   "Query"
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":15E2
            Key             =   "Chart"
         EndProperty
      EndProperty
   End
   Begin VB.TextBox txtInput 
      Alignment       =   1  'Right Justify
      Appearance      =   0  'Flat
      Height          =   270
      Left            =   2400
      TabIndex        =   0
      Top             =   2400
      Visible         =   0   'False
      Width           =   1335
   End
   Begin MSFlexGridLib.MSFlexGrid Grid 
      Height          =   5295
      Left            =   0
      TabIndex        =   1
      Top             =   600
      Width           =   8655
      _ExtentX        =   15266
      _ExtentY        =   9340
      _Version        =   393216
      AllowUserResizing=   1
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Form_Load()
    Dim i As Integer
    Set recset = db.OpenRecordset("成绩")       '打开记录集
    Set recmajor = db.OpenRecordset("专业")     '打开记录集
    Set recschool = db.OpenRecordset("院系")    '打开记录集
    Grid.FormatString = "^序号|<姓 名|<  院  系  |<  专  业  |>年级|>高等数学|>大学英语|>普通物理|>电子技术"
    Grid.Rows = recset.RecordCount + 1
    For i = 1 To Grid.Rows - 1                  '显示序号
           Grid.TextMatrix(i, 0) = i
    Next
    i = 0
    With recset                                 '显示记录信息
        Do While Not .EOF
           i = i + 1
           Grid.TextMatrix(i, 1) = !姓名
           Grid.TextMatrix(i, 2) = GetSchool(!院系)
           Grid.TextMatrix(i, 3) = GetMajor(!专业, !院系)
           Grid.TextMatrix(i, 4) = !年级
           Grid.TextMatrix(i, 5) = !高等数学
           Grid.TextMatrix(i, 6) = !大学英语
           Grid.TextMatrix(i, 7) = !普通物理
           Grid.TextMatrix(i, 8) = !电子技术
           .MoveNext                           '下一条记录
        Loop
    End With
End Sub

Private Sub Form_Resize()
    Grid.Width = Me.ScaleWidth - Grid.Left
    Grid.Height = Me.ScaleHeight - Grid.Top
End Sub

Private Sub Form_Unload(Cancel As Integer)
    recset.Close        '关闭记录集
    recmajor.Close
    recschool.Close
    db.Close            '关闭数据库
End Sub

Private Sub Grid_EnterCell()
    If Grid.MouseCol < 5 Then
        txtInput.Visible = False
        Exit Sub
    Else
      txtInput.Visible = True
      txtInput.Left = Grid.Left + Grid.CellLeft
      txtInput.Top = Grid.Top + Grid.CellTop
      txtInput.Width = Grid.CellWidth
      txtInput.Height = Grid.CellHeight
      txtInput.Text = Grid.Text
      txtInput.SetFocus
    End If
End Sub
'
Private Sub Grid_LeaveCell()
    If Grid.Col < 5 Then
        Exit Sub
    Else
        Grid.Text = txtInput.Text
        recset.MoveFirst
        recset.Move Grid.Row - 1
        recset.Edit
        Select Case Grid.Col
            Case 5
                recset!高等数学 = Val(Left(txtInput.Text, 3))
             Case 6
                recset!大学英语 = Val(Left(txtInput.Text, 3))
            Case 7
                recset!普通物理 = Val(Left(txtInput.Text, 3))
            Case 8
                recset!电子技术 = Val(Left(txtInput.Text, 3))
        End Select
        recset.Update
        
    End If
    txtInput.Visible = False
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    Dim i As Integer
    Dim j As Integer
    Select Case Button.Key
        Case "Append"
            frmAppend.Show 1, Me
        Case "Delete"
            If MsgBox("是否要删除 " & Grid.TextMatrix(Grid.Row, 1) & " 的数据?", vbQuestion + vbYesNo) = vbNo Then Exit Sub
            recset.MoveFirst
            recset.Move Grid.Row - 1
            recset.Delete
            For i = Grid.Row To Grid.Rows - 2
                For j = 0 To Grid.Cols - 1
                    Grid.TextMatrix(i, j) = Grid.TextMatrix(i + 1, j)
                Next
            Next
            Grid.Rows = Grid.Rows - 1
        Case "Query"
            frmQuery.Show 1, Me
        Case "Password"
            frmPassword.Show 1, Me
        Case "Chart"
            frmChart.Show 1, Me
        Case "Exit"
            Unload Me
    End Select
End Sub

⌨️ 快捷键说明

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