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

📄 frmbookedit.frm

📁 vb与access数据库的操作实例
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FrmBookEdit 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "编辑图书基本信息"
   ClientHeight    =   5760
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6165
   Icon            =   "FrmBookEdit.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5760
   ScaleWidth      =   6165
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Cmd_OK 
      Caption         =   "确 定"
      Default         =   -1  'True
      Height          =   400
      Left            =   1320
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   5160
      Width           =   1300
   End
   Begin VB.CommandButton Cmd_Cancel 
      Cancel          =   -1  'True
      Caption         =   "取 消"
      Height          =   400
      Left            =   3480
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   5160
      Width           =   1300
   End
   Begin VB.Frame Frame1 
      Height          =   4815
      Left            =   120
      TabIndex        =   6
      Top             =   120
      Width           =   5895
      Begin VB.TextBox txtSubType 
         Enabled         =   0   'False
         Height          =   330
         Left            =   4200
         TabIndex        =   20
         Top             =   1260
         Width           =   1575
      End
      Begin VB.TextBox txtType 
         Enabled         =   0   'False
         Height          =   330
         Left            =   1200
         TabIndex        =   19
         Top             =   1260
         Width           =   1575
      End
      Begin VB.TextBox txtDescription 
         Height          =   855
         Left            =   1200
         MultiLine       =   -1  'True
         TabIndex        =   18
         Top             =   3720
         Width           =   4575
      End
      Begin VB.TextBox txtPrice 
         Alignment       =   1  'Right Justify
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1200
         MaxLength       =   20
         TabIndex        =   14
         Text            =   "0"
         Top             =   3165
         Width           =   1695
      End
      Begin VB.TextBox txtLocation 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1200
         MaxLength       =   20
         TabIndex        =   11
         Top             =   2685
         Width           =   4575
      End
      Begin VB.TextBox txtAuthor 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1200
         MaxLength       =   50
         TabIndex        =   2
         Top             =   1725
         Width           =   4575
      End
      Begin VB.TextBox txtPublisher 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1200
         MaxLength       =   20
         TabIndex        =   3
         Top             =   2205
         Width           =   4575
      End
      Begin VB.TextBox txtBookNo 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1200
         MaxLength       =   100
         TabIndex        =   0
         Top             =   285
         Width           =   4575
      End
      Begin VB.TextBox txtBookName 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1200
         MaxLength       =   100
         TabIndex        =   1
         Top             =   765
         Width           =   4575
      End
      Begin VB.Label Label9 
         Caption         =   "二级分类"
         Height          =   180
         Left            =   3240
         TabIndex        =   17
         Top             =   1320
         Width           =   720
      End
      Begin VB.Label Label7 
         Caption         =   "内容简介"
         Height          =   180
         Left            =   240
         TabIndex        =   16
         Top             =   3720
         Width           =   720
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "图书分类"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   15
         Top             =   1320
         Width           =   720
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "价    格"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   13
         Top             =   3240
         Width           =   720
      End
      Begin VB.Label Label3 
         BackStyle       =   0  'Transparent
         Caption         =   "书架位置"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   12
         Top             =   2760
         Width           =   720
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFC0C0&
         BackStyle       =   0  'Transparent
         Caption         =   "图书名称"
         Height          =   180
         Left            =   240
         TabIndex        =   10
         Top             =   840
         Width           =   720
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "作    者"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   9
         Top             =   1800
         Width           =   720
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "出 版 社"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   8
         Top             =   2280
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "图书编号"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   7
         Top             =   360
         Width           =   720
      End
   End
End
Attribute VB_Name = "FrmBookEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Modify As Boolean '插入=false,修改=true
Public OriNo As String   '原始图书编号
Public nBookTypeId As Integer  '图书分类编号

Private Sub Cmd_Cancel_Click()
  Unload Me
End Sub

Private Sub Cmd_OK_Click()
  '检查用户录入数据的有效性
  If Len(Trim(txtBookNo)) = 0 Then
    MsgBox "请输入图书编号!"
    txtBookNo.SetFocus
    txtBookNo.SelStart = 0
    txtBookNo.SelLength = Len(txtBookNo)
    Exit Sub
  End If
  If Len(Trim(txtBookName)) = 0 Then
    MsgBox "请输入图书名称"
    txtBookName.SetFocus
    txtBookName.SelStart = 0
    txtBookName.SelLength = Len(txtBookName)
    Exit Sub
  End If
  
  If Len(Trim(txtPublisher)) = 0 Then
    MsgBox "请输入出版社"
    txtPublisher.SetFocus
    txtPublisher.SelStart = 0
    txtPublisher.SelLength = Len(txtPublisher)
    Exit Sub
  End If
  If Len(Trim(txtPrice)) = 0 Then
    MsgBox "请输入图书价格"
    txtPrice.SetFocus
    txtPrice.SelStart = 0
    txtPrice.SelLength = Len(txtPrice)
    Exit Sub
  End If

  '把用户录入的数据赋值到数据库对象变量中
  With MyBookInfo
  .BookNo = MakeStr(txtBookNo)          '图书编号
  .BookName = MakeStr(txtBookName)      '图书名称
  .Publisher = MakeStr(txtPublisher)    '出版社
  .Author = MakeStr(txtAuthor)          '作者
  .Location = MakeStr(txtLocation)      '存放位置
  .Price = Val(txtPrice)                '价格
  .TypeId = nBookTypeId                 '图书分类
  .Description = MakeStr(txtDescription)
  '根据变量Modify的值,决定是插入新数据,还是修改已有的数据
  If Modify = False Then
    .Insert
    Cmd_OK.Enabled = False
  Else
    Call .Update(OriNo)
  End If
  End With
  MsgBox "保存成功"
  Unload Me
End Sub

Private Sub txtAuthor_KeyPress(KeyAscii As Integer)
  EnterTAB (KeyAscii)
End Sub

Private Sub txtBookName_KeyPress(KeyAscii As Integer)
  EnterTAB (KeyAscii)
End Sub

Private Sub txtBookNo_KeyPress(KeyAscii As Integer)
  EnterTAB (KeyAscii)
End Sub

Private Sub txtPrice_KeyPress(KeyAscii As Integer)
  EnterTAB (KeyAscii)
  If In_Single(KeyAscii) = False Then
    KeyAscii = 0
  End If
End Sub

Private Sub txtLocation_KeyPress(KeyAscii As Integer)
  EnterTAB (KeyAscii)
End Sub

Private Sub txtPublisher_KeyPress(KeyAscii As Integer)
  EnterTAB (KeyAscii)
End Sub

⌨️ 快捷键说明

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