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

📄 frmmain.frm

📁 《VB6数据库开发指南》所有的例程的源码
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmMain 
   Caption         =   "Authors"
   ClientHeight    =   4230
   ClientLeft      =   165
   ClientTop       =   735
   ClientWidth     =   5415
   LinkTopic       =   "Form1"
   ScaleHeight     =   4230
   ScaleWidth      =   5415
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox txtId 
      DataField       =   "au_id"
      DataSource      =   "adodc"
      Height          =   375
      Left            =   120
      TabIndex        =   15
      Top             =   360
      Width           =   2535
   End
   Begin VB.CheckBox chkContract 
      Caption         =   "Contract"
      DataField       =   "contract"
      DataSource      =   "adodc"
      Height          =   375
      Left            =   2760
      TabIndex        =   14
      Top             =   3240
      Width           =   1935
   End
   Begin VB.TextBox txtPhone 
      DataField       =   "phone"
      DataSource      =   "adodc"
      Height          =   375
      Left            =   120
      TabIndex        =   12
      Top             =   3240
      Width           =   2535
   End
   Begin VB.TextBox txtZip 
      DataField       =   "zip"
      DataSource      =   "adodc"
      Height          =   375
      Left            =   3720
      TabIndex        =   5
      Top             =   2520
      Width           =   1575
   End
   Begin VB.TextBox txtState 
      DataField       =   "state"
      DataSource      =   "adodc"
      Height          =   375
      Left            =   2760
      TabIndex        =   4
      Top             =   2520
      Width           =   855
   End
   Begin VB.TextBox txtCity 
      DataField       =   "city"
      DataSource      =   "adodc"
      Height          =   375
      Left            =   120
      TabIndex        =   3
      Top             =   2520
      Width           =   2535
   End
   Begin VB.TextBox txtAddress 
      DataField       =   "address"
      DataSource      =   "adodc"
      Height          =   375
      Left            =   120
      TabIndex        =   2
      Top             =   1800
      Width           =   5175
   End
   Begin VB.TextBox txtLastName 
      DataField       =   "au_lname"
      DataSource      =   "adodc"
      Height          =   375
      Left            =   2760
      TabIndex        =   1
      Top             =   1080
      Width           =   2535
   End
   Begin VB.TextBox txtFirstName 
      DataField       =   "au_fname"
      DataSource      =   "adodc"
      Height          =   375
      Left            =   120
      TabIndex        =   0
      Top             =   1080
      Width           =   2535
   End
   Begin MSAdodcLib.Adodc adodc 
      Align           =   2  'Align Bottom
      Height          =   390
      Left            =   0
      Top             =   3840
      Width           =   5415
      _ExtentX        =   9551
      _ExtentY        =   688
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   2
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "DSN=pubs;User Id=sa;Password=password"
      OLEDBString     =   "DSN=pubs;User Id=sa;Password=password"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "authors"
      Caption         =   "Authors"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Label lblId 
      Caption         =   "Id"
      Height          =   375
      Left            =   120
      TabIndex        =   16
      Top             =   120
      Width           =   1935
   End
   Begin VB.Label lblPhone 
      Caption         =   "Phone"
      Height          =   375
      Left            =   120
      TabIndex        =   13
      Top             =   3000
      Width           =   1095
   End
   Begin VB.Label lblZip 
      Caption         =   "Zip Code"
      Height          =   375
      Left            =   3720
      TabIndex        =   11
      Top             =   2280
      Width           =   1575
   End
   Begin VB.Label lblState 
      Caption         =   "State"
      Height          =   255
      Left            =   2760
      TabIndex        =   10
      Top             =   2280
      Width           =   855
   End
   Begin VB.Label lblCity 
      Caption         =   "City"
      Height          =   375
      Left            =   120
      TabIndex        =   9
      Top             =   2280
      Width           =   1695
   End
   Begin VB.Label lblAddress 
      Caption         =   "Address"
      Height          =   255
      Left            =   120
      TabIndex        =   8
      Top             =   1560
      Width           =   2175
   End
   Begin VB.Label lblLastName 
      Caption         =   "Last"
      Height          =   375
      Left            =   2760
      TabIndex        =   7
      Top             =   840
      Width           =   1335
   End
   Begin VB.Label lblFirstName 
      Caption         =   "First"
      Height          =   375
      Left            =   120
      TabIndex        =   6
      Top             =   840
      Width           =   1935
   End
   Begin VB.Menu mnuFile 
      Caption         =   "&File"
      Begin VB.Menu mnuNew 
         Caption         =   "&New"
      End
      Begin VB.Menu mnuSave 
         Caption         =   "&Save"
         Enabled         =   0   'False
      End
      Begin VB.Menu mnuExit 
         Caption         =   "E&xit"
      End
   End
   Begin VB.Menu mnuEdit 
      Caption         =   "&Edit"
      Begin VB.Menu mnuDelete 
         Caption         =   "&Delete"
      End
   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 mnuExit_Click()
    If Adodc.Recordset.EditMode = adEditAdd Then
        If MsgBox("Do you want to save?", vbYesNo) = vbYes Then
            Save
        End If
    End If
    Unload Me
End Sub

Private Sub mnuNew_Click()
    Adodc.Recordset.AddNew
    'so we can save that new record
    mnuSave.Enabled = True
End Sub

Private Sub mnuDelete_Click()
    On Error GoTo DeleteFailure:
    Adodc.Recordset.Delete
    'current row is now invalid so move back one
    Adodc.Recordset.MovePrevious
    'if we are before the beginning go to the first
    If Adodc.Recordset.BOF Then
        Adodc.Recordset.MoveFirst
    End If
DeleteDone:
    Exit Sub
DeleteFailure:
    MsgBox Err.Number & vbCrLf & Err.Description
    Resume DeleteDone
End Sub

Private Sub mnuSave_Click()
    Save
End Sub

Private Sub Save()
    'if we need to save then save it
    If Adodc.Recordset.EditMode = adEditAdd Then
        On Error GoTo SaveFailure:
        Adodc.Recordset.Update
        On Error GoTo 0
        'don't need to save so disable that menu
        mnuSave.Enabled = False
    End If
    
SaveDone:
    Exit Sub
SaveFailure:
    MsgBox Err.Number & vbCrLf & Err.Description
    Resume SaveDone
End Sub

⌨️ 快捷键说明

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