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

📄 frmcompanyedit.frm

📁 vb与access数据库的操作实例
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FrmCompanyEdit 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "编辑公司信息"
   ClientHeight    =   4140
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7245
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4140
   ScaleWidth      =   7245
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Cmd_OK 
      Caption         =   "确 定"
      Height          =   400
      Left            =   1800
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   3600
      Width           =   1000
   End
   Begin VB.CommandButton Cmd_Cancel 
      Cancel          =   -1  'True
      Caption         =   "取 消"
      Height          =   400
      Left            =   4320
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   3600
      Width           =   1000
   End
   Begin VB.Frame Frame1 
      Height          =   3495
      Left            =   240
      TabIndex        =   5
      Top             =   0
      Width           =   6735
      Begin VB.TextBox txtComment 
         Height          =   735
         Left            =   1320
         MultiLine       =   -1  'True
         TabIndex        =   18
         Top             =   2520
         Width           =   4935
      End
      Begin VB.TextBox txtFax 
         Height          =   330
         Left            =   4440
         TabIndex        =   16
         Top             =   885
         Width           =   1815
      End
      Begin VB.TextBox txtContact 
         Height          =   330
         Left            =   4440
         TabIndex        =   14
         Top             =   2040
         Width           =   1815
      End
      Begin VB.TextBox txtCompany 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1320
         MaxLength       =   100
         TabIndex        =   13
         Top             =   300
         Width           =   1815
      End
      Begin VB.TextBox txtEmail 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1320
         MaxLength       =   20
         TabIndex        =   6
         Top             =   2040
         Width           =   1815
      End
      Begin VB.TextBox txtAddress 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1320
         MaxLength       =   50
         TabIndex        =   1
         Top             =   1440
         Width           =   1815
      End
      Begin VB.TextBox txtZipCode 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   4440
         MaxLength       =   20
         TabIndex        =   2
         Top             =   1440
         Width           =   1815
      End
      Begin VB.TextBox txtTelephone 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1320
         MaxLength       =   100
         TabIndex        =   0
         Top             =   885
         Width           =   1815
      End
      Begin VB.Label lblType 
         Caption         =   "公司"
         Height          =   255
         Left            =   4440
         TabIndex        =   20
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label9 
         Caption         =   "公司种类"
         Height          =   180
         Left            =   3600
         TabIndex        =   19
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label7 
         Caption         =   "备  注"
         Height          =   180
         Left            =   360
         TabIndex        =   17
         Top             =   2520
         Width           =   615
      End
      Begin VB.Label Label5 
         Caption         =   "传  真"
         Height          =   180
         Left            =   3600
         TabIndex        =   15
         Top             =   960
         Width           =   615
      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            =   360
         TabIndex        =   12
         Top             =   360
         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            =   3600
         TabIndex        =   11
         Top             =   1500
         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            =   360
         TabIndex        =   10
         Top             =   1500
         Width           =   720
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFC0C0&
         BackStyle       =   0  'Transparent
         Caption         =   "联系电话"
         Height          =   180
         Left            =   360
         TabIndex        =   9
         Top             =   960
         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            =   360
         TabIndex        =   8
         Top             =   2100
         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            =   3600
         TabIndex        =   7
         Top             =   2100
         Width           =   540
      End
   End
End
Attribute VB_Name = "FrmCompanyEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Modify As Boolean '插入=false,修改=true
Public nId As Integer  '公司编号
Public nTid As Integer '类别编号,1-汽车销售商;2-保险公司

Private Sub Cmd_Cancel_Click()
  Unload Me
End Sub

Private Sub Cmd_OK_Click()
  '检查用户录入数据的有效性
  If Len(Trim(txtCompany)) = 0 Then
    MsgBox "请输入公司名称!"
    txtCompany.SetFocus
    Exit Sub
  End If
  If Len(Trim(txtTelephone)) = 0 Then
    MsgBox "请输入联系电话"
    txtTelephone.SetFocus
    Exit Sub
  End If
  '把用户录入的数据赋值到数据库对象变量中
  With MyCompany
    .Company = MakeStr(txtCompany)      '公司名称
    .Telephone = MakeStr(txtTelephone)  '电话
    .Fax = MakeStr(txtFax)              '传真
    .Address = MakeStr(txtAddress)      '地址
    .Email = MakeStr(txtEmail)          '电子邮件
    .Contact = MakeStr(txtContact)      '联系人
    .ZipCode = MakeStr(txtZipCode)      '邮政编码
    .TypeId = nTid                      '种类
    .Comment = MakeStr(txtComment)      '说明
    If Modify = False Then
      .Insert                   '插入新数据
    Else
      .Update (nId)             '修改已有的数据
    End If
  End With
  '关闭窗口
  Unload Me
End Sub

⌨️ 快捷键说明

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