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

📄 v6bj11-08.frm

📁 内有多个vb6.0数据库编写程序 可以让大家参考 希望对这个站有帮助....
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form11 
   Caption         =   "VB6 例11-08 用SQL查找数据"
   ClientHeight    =   1830
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4980
   LinkTopic       =   "Form1"
   ScaleHeight     =   1830
   ScaleWidth      =   4980
   StartUpPosition =   3  '窗口缺省
   Begin VB.PictureBox Picture1 
      AutoSize        =   -1  'True
      DataField       =   "照片"
      DataSource      =   "Data1"
      Height          =   855
      Left            =   120
      ScaleHeight     =   795
      ScaleWidth      =   675
      TabIndex        =   10
      Top             =   60
      Width           =   735
   End
   Begin VB.TextBox Text3 
      DataField       =   "性别"
      DataSource      =   "Data1"
      Height          =   375
      Left            =   4440
      TabIndex        =   9
      Top             =   60
      Width           =   375
   End
   Begin VB.TextBox Text5 
      DataField       =   "出生年月"
      DataSource      =   "Data1"
      Height          =   375
      Left            =   3660
      TabIndex        =   8
      Top             =   540
      Width           =   1215
   End
   Begin VB.TextBox Text4 
      DataField       =   "专业"
      DataSource      =   "Data1"
      Height          =   375
      Left            =   1440
      TabIndex        =   7
      Top             =   540
      Width           =   1335
   End
   Begin VB.TextBox Text2 
      DataField       =   "姓名"
      DataSource      =   "Data1"
      Height          =   375
      Left            =   2760
      TabIndex        =   6
      Top             =   60
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      DataField       =   "学号"
      DataSource      =   "Data1"
      Height          =   375
      Left            =   1440
      TabIndex        =   5
      Top             =   60
      Width           =   855
   End
   Begin VB.CommandButton Command5 
      Caption         =   "查找"
      Height          =   315
      Left            =   3720
      TabIndex        =   4
      Top             =   1020
      Width           =   795
   End
   Begin VB.CommandButton Command4 
      Caption         =   "放弃"
      Enabled         =   0   'False
      Height          =   315
      Left            =   2820
      TabIndex        =   3
      Top             =   1020
      Width           =   795
   End
   Begin VB.CommandButton Command3 
      Caption         =   "修改"
      Height          =   315
      Left            =   1920
      TabIndex        =   2
      Top             =   1020
      Width           =   795
   End
   Begin VB.CommandButton Command2 
      Caption         =   "删除"
      Height          =   315
      Left            =   1020
      TabIndex        =   1
      Top             =   1020
      Width           =   795
   End
   Begin VB.CommandButton Command1 
      Caption         =   "新增"
      Height          =   315
      Left            =   120
      TabIndex        =   0
      Top             =   1020
      Width           =   795
   End
   Begin VB.Data Data1 
      Align           =   2  'Align Bottom
      Caption         =   "基本情况"
      Connect         =   "Access"
      DatabaseName    =   "Student.mdb"
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   0
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "基本情况"
      Top             =   1485
      Width           =   4980
   End
   Begin VB.Label Label1 
      Caption         =   "学号"
      Height          =   255
      Index           =   0
      Left            =   960
      TabIndex        =   15
      Top             =   180
      Width           =   495
   End
   Begin VB.Label Label1 
      Caption         =   "性别"
      Height          =   255
      Index           =   4
      Left            =   4050
      TabIndex        =   14
      Top             =   180
      Width           =   405
   End
   Begin VB.Label Label1 
      Caption         =   "年龄"
      Height          =   255
      Index           =   3
      Left            =   3060
      TabIndex        =   13
      Top             =   600
      Width           =   495
   End
   Begin VB.Label Label1 
      Caption         =   "专业"
      Height          =   255
      Index           =   2
      Left            =   960
      TabIndex        =   12
      Top             =   660
      Width           =   495
   End
   Begin VB.Label Label1 
      Caption         =   "姓名"
      Height          =   255
      Index           =   1
      Left            =   2340
      TabIndex        =   11
      Top             =   180
      Width           =   495
   End
End
Attribute VB_Name = "Form11"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
    On Error Resume Next
    Command2.Enabled = Not Command2.Enabled
    Command3.Enabled = Not Command3.Enabled
    Command4.Enabled = Not Command4.Enabled
    Command5.Enabled = Not Command5.Enabled
   If Command1.Caption = "新增" Then
        Command1.Caption = "确认"
        Data1.Recordset.AddNew
        Text1.SetFocus
    Else
        Command1.Caption = "新增"
        Data1.Recordset.Update
 '       Data1.Recordset.MoveLast
    End If
End Sub

Private Sub Command2_Click()
    On Error Resume Next
   Data1.Recordset.Delete
    Data1.Recordset.MoveNext
    If Data1.Recordset.EOF Then Data1.Recordset.MoveLast
End Sub

Private Sub Command3_Click()
On Error Resume Next
   Command1.Enabled = Not Command1.Enabled
    Command2.Enabled = Not Command2.Enabled
    Command4.Enabled = Not Command4.Enabled
    Command5.Enabled = Not Command5.Enabled
   If Command3.Caption = "修改" Then
        Command3.Caption = "确认"
        Data1.Recordset.Edit
        Text1.SetFocus
    Else
        Command3.Caption = "修改"
        Data1.Recordset.Update
    End If
End Sub

Private Sub Command4_Click()
     On Error Resume Next
    Command1.Caption = "新增": Command3.Caption = "修改"
    Command1.Enabled = True: Command2.Enabled = True
    Command3.Enabled = True: Command4.Enabled = False
    Command5.Enabled = True
    Data1.UpdateControls
    Data1.Recordset.MoveLast
End Sub

Private Sub Command5_Click()
    Dim mzy As String
    mzy = InputBox$("请输入专业", "查找窗")
    Data1.RecordSource = "Select * From 基本情况 Where 专业 like '" & mzy & "' "
    Data1.Refresh
    If Data1.Recordset.EOF Then
        MsgBox "无此专业!", , "提示"
        Data1.RecordSource = "基本情况"
        Data1.Refresh
    End If
End Sub

Private Sub Data1_Reposition()
    Data1.Caption = Data1.Recordset.AbsolutePosition + 1
End Sub

Private Sub Data1_Validate(Action As Integer, Save As Integer)
If Text1.Text = "" And (Action = 6 Or Text1.DataChanged) Then
    Data1.UpdateControls
MsgBox "数据不完整,必须要有学号!"
End If

If Action >= 1 And Action < 5 Then
    Command1.Caption = "新增": Command3.Caption = "修改"
    Command1.Enabled = True: Command2.Enabled = True
    Command3.Enabled = True: Command4.Enabled = False
    Command5.Enabled = True
End If
End Sub

Private Sub Form_Load()
    mpath = App.Path
    If Right(mpath, 1) <> "\" Then mpath = mpath + "\"
    Data1.DatabaseName = mpath + "student.mdb"
End Sub

Private Sub Picture1_DblClick()
    Picture1.Picture = Clipboard.GetData
End Sub

⌨️ 快捷键说明

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