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

📄 frmtype.frm

📁 <Visual Basic 数据库开发实例精粹(第二版)>一书首先介绍了Visual Basic(简称VB)开发的技巧和重点技术
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmType 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "商品类型管理"
   ClientHeight    =   2835
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5820
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   2835
   ScaleWidth      =   5820
   StartUpPosition =   1  '所有者中心
   Begin VB.Frame FrameBG 
      Height          =   2970
      Left            =   0
      TabIndex        =   4
      Top             =   -135
      Width           =   5820
      Begin VB.PictureBox picTitle 
         Appearance      =   0  'Flat
         BackColor       =   &H00808080&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   360
         Left            =   30
         ScaleHeight     =   360
         ScaleWidth      =   5745
         TabIndex        =   5
         TabStop         =   0   'False
         Top             =   120
         Width           =   5745
         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        =   6
            Top             =   90
            Width           =   1350
         End
      End
      Begin VB.TextBox txt 
         Height          =   270
         Index           =   0
         Left            =   1095
         MaxLength       =   50
         TabIndex        =   0
         Top             =   750
         Width           =   4455
      End
      Begin VB.TextBox txt 
         Height          =   990
         Index           =   1
         Left            =   1095
         MaxLength       =   500
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   1
         Top             =   1140
         Width           =   4440
      End
      Begin VB.CommandButton cmdType 
         Caption         =   "添加(&A)"
         Height          =   375
         Left            =   3000
         TabIndex        =   2
         Top             =   2385
         Width           =   1080
      End
      Begin VB.CommandButton cmdCancel 
         Cancel          =   -1  'True
         Caption         =   "取消(&C)"
         Height          =   375
         Left            =   4305
         TabIndex        =   3
         Top             =   2385
         Width           =   1080
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "类型名称"
         Height          =   180
         Left            =   285
         TabIndex        =   8
         Top             =   780
         Width           =   720
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "备注"
         Height          =   180
         Left            =   300
         TabIndex        =   7
         Top             =   1200
         Width           =   360
      End
   End
End
Attribute VB_Name = "frmType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim GoodsType As clsGoodsType     '商品类型对象

Private Sub cmdType_Click()
  '必须填写商品类型名称
  If txt(0) = "" Then MsgBox "请填写类型名称!", vbInformation: Exit Sub
  
  '初始化商品类型对象
  Set GoodsType = New clsGoodsType
  With GoodsType
    '为商品类型对象的属性赋值
    .TypeName = Trim(txt(0))
    .Remark = IIf(Trim(txt(1)) = "", "无", RTrim(txt(1)))
    '根据cmdType的Caption属性修改或添加商品类型对象
    Select Case cmdType.Caption
      Case "修改(&M)": UpdateType  '修改商品类型对象
      Case Else: AddNewType        '添加商品类型对象
    End Select
  End With
  txt(0).SetFocus
End Sub

'更新商品类型对象
Private Sub UpdateType()
  Dim UpdateResult As gxcUpdate    '更新结果
  '指定商品类型对象的ID属性
  GoodsType.ID = Me.Tag
  '更新商品类型对象并返回更新结果
  UpdateResult = GoodsType.Update
  '与其他项目的更新不同,这里要考虑到同时更新树形视图相应节点的文本
  UpdateTypeFromTvwEx GoodsType
  '同步更新列表视图并弹出提示消息框
  ProcUpdateResult UpdateResult, GoodsType
End Sub

'添加商品类型对象
Private Sub AddNewType()
  Dim AddNewResult As gxcAddNew    '添加结果
  '添加商品类型对象并返回添加结果
  AddNewResult = GoodsType.AddNew
  '添加成功之后的操作
  If AddNewResult = AddNewOK Then
     txt(0) = "": txt(1) = ""
     '在树形视图上添加商品类型
     AddTypeToTvw GoodsType
     '当前操作处于浏览商品类型信息状态,则在列表视图上添加商品类型信息
     If CurrentOperation = BrowseType Then ShowObjInLvw GoodsType
     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 + -