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

📄 frmstuinfoman.frm

📁 简单的数据哭访问程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmStuInfoMan 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "学生信息管理"
   ClientHeight    =   4890
   ClientLeft      =   2610
   ClientTop       =   2955
   ClientWidth     =   6750
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4890
   ScaleWidth      =   6750
   ShowInTaskbar   =   0   'False
   Begin VB.Frame Frame3 
      Height          =   855
      Left            =   120
      TabIndex        =   19
      Top             =   3840
      Width           =   6495
      Begin VB.CommandButton cmdSave 
         Caption         =   "保存(&S)"
         Enabled         =   0   'False
         Height          =   255
         Left            =   3840
         TabIndex        =   24
         Top             =   360
         Width           =   975
      End
      Begin VB.CommandButton cmdClose 
         Caption         =   "关闭(&E)"
         Height          =   255
         Left            =   5160
         TabIndex        =   23
         Top             =   360
         Width           =   975
      End
      Begin VB.CommandButton cmdUpdate 
         Caption         =   "更新(&U)"
         Height          =   255
         Left            =   2640
         TabIndex        =   22
         Top             =   360
         Width           =   975
      End
      Begin VB.CommandButton cmdDel 
         Caption         =   " 删除(&D)"
         Height          =   255
         Left            =   1560
         TabIndex        =   21
         Top             =   360
         Width           =   855
      End
      Begin VB.CommandButton cmdAdd 
         Caption         =   "增加(&A)"
         Height          =   255
         Left            =   360
         TabIndex        =   20
         Top             =   360
         Width           =   975
      End
   End
   Begin VB.Frame Frame2 
      Height          =   855
      Left            =   120
      TabIndex        =   14
      Top             =   2880
      Width           =   6495
      Begin VB.CommandButton cmdLast 
         Caption         =   ">|"
         Height          =   255
         Left            =   5160
         TabIndex        =   18
         Top             =   360
         Width           =   975
      End
      Begin VB.CommandButton cmdNext 
         Caption         =   ">"
         Height          =   255
         Left            =   3600
         TabIndex        =   17
         Top             =   360
         Width           =   975
      End
      Begin VB.CommandButton cmdPre 
         Caption         =   "<"
         Height          =   255
         Left            =   2040
         TabIndex        =   16
         Top             =   360
         Width           =   975
      End
      Begin VB.CommandButton cmdFirst 
         Caption         =   "|<"
         Height          =   255
         Left            =   480
         TabIndex        =   15
         Top             =   360
         Width           =   975
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "学生的信息"
      Height          =   2655
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6495
      Begin VB.TextBox txtTel 
         Height          =   285
         Left            =   4800
         TabIndex        =   13
         Top             =   1920
         Width           =   1455
      End
      Begin VB.OptionButton optM 
         Caption         =   "女"
         Height          =   255
         Left            =   5640
         TabIndex        =   12
         Top             =   1320
         Width           =   735
      End
      Begin VB.OptionButton optF 
         Caption         =   "男"
         Height          =   255
         Left            =   4920
         TabIndex        =   11
         Top             =   1320
         Width           =   615
      End
      Begin VB.TextBox txtStuName 
         Height          =   285
         Left            =   4800
         TabIndex        =   10
         Top             =   600
         Width           =   1455
      End
      Begin VB.TextBox txtCorId 
         Height          =   285
         Left            =   1200
         TabIndex        =   9
         Top             =   1920
         Width           =   1455
      End
      Begin VB.TextBox txtStuage 
         Height          =   285
         Left            =   1200
         TabIndex        =   8
         Top             =   1200
         Width           =   1455
      End
      Begin VB.TextBox txtStuId 
         Height          =   285
         Left            =   1200
         TabIndex        =   7
         Top             =   600
         Width           =   1455
      End
      Begin VB.Label Label6 
         Caption         =   "telno"
         Height          =   495
         Left            =   3720
         TabIndex        =   6
         Top             =   1920
         Width           =   855
      End
      Begin VB.Label Label5 
         Caption         =   "courseId"
         Height          =   495
         Left            =   360
         TabIndex        =   5
         Top             =   1920
         Width           =   1335
      End
      Begin VB.Label Label4 
         Caption         =   "sex"
         Height          =   495
         Left            =   3720
         TabIndex        =   4
         Top             =   1320
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "age"
         Height          =   495
         Left            =   360
         TabIndex        =   3
         Top             =   1200
         Width           =   615
      End
      Begin VB.Label Label2 
         Caption         =   "studentname"
         Height          =   495
         Left            =   3720
         TabIndex        =   2
         Top             =   600
         Width           =   1335
      End
      Begin VB.Label Label1 
         Caption         =   "studentId:"
         Height          =   495
         Left            =   360
         TabIndex        =   1
         Top             =   600
         Width           =   975
      End
   End
End
Attribute VB_Name = "frmStuInfoMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdAdd_Click()
    Dim ctr As Control
    For Each ctr In Controls
        If TypeOf ctr Is TextBox Then
            ctr.Text = ""
        End If
    Next
    cmdSave.Enabled = True
End Sub

Private Sub cmdClose_Click()
    Unload Me
End Sub

Private Sub cmdDel_Click()
    g_DBrs.Delete
    cmdNext_Click
End Sub

Private Sub cmdFirst_Click()
    If Not g_DBrs.BOF Then
        g_DBrs.MoveFirst
        dis
    Else
        MsgBox "已是第一条了!"
    End If
End Sub

Private Sub cmdLast_Click()
    If Not g_DBrs.EOF Then
        g_DBrs.MoveLast
        dis
    End If
End Sub

Private Sub cmdNext_Click()
    If Not g_DBrs.EOF Then
        g_DBrs.MoveNext
        dis
    Else
        MsgBox " 已经到达最后一条了."
    End If
End Sub

Private Sub cmdPre_Click()
    If Not g_DBrs.BOF Then
        g_DBrs.MovePrevious
        dis
    Else
        MsgBox " 已经到达第一条了."
    End If
End Sub

Private Sub cmdSave_Click()
    Dim strsql As String
    strsql = "insert into student (studentId, studentname, age,courseId,telno,sex) values "
    strsql = strsql & "( " & Val(txtStuId) & ",'" & txtStuName & "'," & txtStuage & ",'" & txtCorId & "','" & txtTel & "',"
    If optF.Value = True Then
        strsql = strsql & "'男')"
    ElseIf optM.Value = True Then
        strsql = strsql & "'女')"
    Else
        strsql = strsql & "' ')"
    End If
    Debug.Print strsql
    
    'g_DBcon.Execute (strsql)
    'g_DBrs.Requery
End Sub

Private Sub cmdUpdate_Click()
    update
    g_DBrs.update
    cmdClose.Enabled = False
End Sub

Private Sub Form_Load()
    Dim strsql As String
    strsql = "SELECT studentId, studentname,address, age,courseId,telno,sex FROM student"
    ConnecToServer
    QueryData (strsql)
    dis
End Sub
Private Sub dis()
    On Error Resume Next
    If g_DBrs.State Then
        txtStuId.Text = g_DBrs!studentid
        txtStuName.Text = g_DBrs!studentname
        txtStuage.Text = g_DBrs!age
        txtCorId.Text = g_DBrs!courseId
        txtTel.Text = g_DBrs!telno
        If Trim(g_DBrs!sex) = "男" Then
            optF.Value = True
        ElseIf Trim(g_DBrs!sex) = "女" Then
            optM.Value = True
        Else
            optM.Value = False
            optF.Value = False
        End If
            
    End If
End Sub
Private Sub update()
    On Error Resume Next
    If g_DBrs.State Then
        g_DBrs!studentid = txtStuId.Text
        g_DBrs!studentname = txtStuName.Text
        g_DBrs!age = txtStuage.Text
        g_DBrs!courseId = txtCorId.Text
        g_DBrs!telno = txtTel.Text
        If optF.Value = True Then
            Trim(g_DBrs!sex) = "男"
        ElseIf optM.Value = True Then
            Trim(g_DBrs!sex) = "女"
        Else
            optM.Value = False
            optF.Value = False
        End If
            
    End If
End Sub

⌨️ 快捷键说明

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