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

📄 frmsupplier.frm

📁 <Visual Basic 数据库开发实例精粹(第二版)>一书首先介绍了Visual Basic(简称VB)开发的技巧和重点技术
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmSupplier 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "供货商管理"
   ClientHeight    =   3495
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6465
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   3495
   ScaleWidth      =   6465
   StartUpPosition =   1  '所有者中心
   Begin VB.Frame FrameBG 
      Height          =   3630
      Left            =   0
      TabIndex        =   6
      Top             =   -135
      Width           =   6465
      Begin VB.PictureBox picTitle 
         Appearance      =   0  'Flat
         BackColor       =   &H00808080&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   360
         Left            =   30
         ScaleHeight     =   360
         ScaleWidth      =   6420
         TabIndex        =   7
         TabStop         =   0   'False
         Top             =   120
         Width           =   6420
         Begin VB.Label lblTitle 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "登记供货商"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   10.5
               Charset         =   134
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   210
            Left            =   255
            TabIndex        =   8
            Top             =   90
            Width           =   1125
         End
      End
      Begin VB.TextBox txt 
         Height          =   270
         Index           =   0
         Left            =   1410
         MaxLength       =   50
         TabIndex        =   0
         Top             =   750
         Width           =   4695
      End
      Begin VB.TextBox txt 
         Height          =   270
         Index           =   1
         Left            =   1410
         MaxLength       =   500
         TabIndex        =   1
         Top             =   1110
         Width           =   4695
      End
      Begin VB.TextBox txt 
         Height          =   270
         Index           =   2
         Left            =   1410
         MaxLength       =   500
         TabIndex        =   2
         Top             =   1470
         Width           =   4695
      End
      Begin VB.CommandButton cmdSupplier 
         Caption         =   "确定(&O)"
         Height          =   375
         Left            =   3525
         TabIndex        =   4
         Top             =   3045
         Width           =   1080
      End
      Begin VB.CommandButton cmdCancel 
         Cancel          =   -1  'True
         Caption         =   "取消(&C)"
         Height          =   375
         Left            =   4875
         TabIndex        =   5
         Top             =   3045
         Width           =   1080
      End
      Begin VB.TextBox txt 
         Height          =   990
         Index           =   3
         Left            =   1410
         MaxLength       =   500
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   3
         Top             =   1830
         Width           =   4695
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "供货商名称"
         Height          =   180
         Left            =   345
         TabIndex        =   12
         Top             =   795
         Width           =   900
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "联系方式"
         Height          =   180
         Left            =   345
         TabIndex        =   11
         Top             =   1170
         Width           =   720
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "简要介绍"
         Height          =   180
         Left            =   345
         TabIndex        =   10
         Top             =   1530
         Width           =   720
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "备注"
         Height          =   180
         Left            =   345
         TabIndex        =   9
         Top             =   1890
         Width           =   360
      End
   End
End
Attribute VB_Name = "frmSupplier"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Supplier As clsSupplier     '供货商对象

Private Sub cmdSupplier_Click()
  '必须填写供货商名称
  If txt(0) = "" Then MsgBox "请填写完整!", vbInformation: Exit Sub
  
  '初始化供货商对象
  Set Supplier = New clsSupplier
  With Supplier
    '为供货商对象的属性赋值
    .SupplierName = Trim(txt(0))
    .Contact = IIf(Trim(txt(1)) = "", "无", Trim(txt(1)))
    .Introduce = IIf(Trim(txt(2)) = "", "无", Trim(txt(2)))
    .Remark = IIf(Trim(txt(3)) = "", "无", RTrim(txt(3)))
    '根据cmdSupplier的Caption属性修改或添加供货商对象
    Select Case cmdSupplier.Caption
      Case "修改(&M)": UpdateSupplier  '修改供货商对象
      Case Else: AddNewSupplier        '添加供货商对象
    End Select
  End With
  txt(0).SetFocus
End Sub

'更新供货商对象
Private Sub UpdateSupplier()
  Dim UpdateResult As gxcUpdate   '更新结果
  '指定供货商对象的ID属性
  Supplier.ID = Me.Tag
  '更新供货商对象并返回更新结果
  UpdateResult = Supplier.Update
  '同步更新列表视图并弹出提示消息框
  ProcUpdateResult UpdateResult, Supplier
End Sub

'添加供货商对象
Private Sub AddNewSupplier()
  Dim AddNewResult As gxcAddNew   '添加结果
  '添加供货商对象并返回添加结果
  AddNewResult = Supplier.AddNew
  '添加成功之后的操作
  If AddNewResult = AddNewOK Then
     txt(0) = "": txt(1) = "": txt(2) = "": txt(3) = ""
     '当前操作处于浏览供货商信息状态,则在列表视图上添加供货商信息
     If CurrentOperation = BrowseSupplier Then ShowObjInLvw Supplier
     MsgBox "登记成功!", vbInformation
     Exit Sub
  End If
  '添加失败后的操作(消息框提示用户)
  ProcAddNewResult AddNewResult
End Sub

Private Sub cmdCancel_Click()
  Unload Me
End Sub

'文本框获得焦点时选中所有文字
Private Sub txt_GotFocus(Index As Integer)
  txt(Index).SelStart = 0                   '选中文字的起始位置
  txt(Index).SelLength = Len(txt(Index))    '选中文字的长度
End Sub

⌨️ 快捷键说明

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