📄 frmitype.frm
字号:
VERSION 5.00
Begin VB.Form frmIType
Caption = "图像类型信息"
ClientHeight = 4665
ClientLeft = 60
ClientTop = 450
ClientWidth = 6330
LinkTopic = "Form1"
ScaleHeight = 4665
ScaleWidth = 6330
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton CancelButton
Caption = "取消"
Height = 375
Left = 4680
TabIndex = 6
Top = 3960
Width = 1095
End
Begin VB.CommandButton OKButton
Caption = "确定"
Height = 375
Left = 2880
TabIndex = 5
Top = 3960
Width = 1095
End
Begin VB.Frame fraPType
Caption = "图像类型信息"
Height = 3255
Left = 360
TabIndex = 0
Top = 360
Width = 5415
Begin VB.TextBox txtRemark
Height = 1575
Left = 1680
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 4
Text = "frmIType.frx":0000
Top = 1440
Width = 2295
End
Begin VB.TextBox txtName
Height = 285
Left = 1680
TabIndex = 3
Text = "Text1"
Top = 480
Width = 2295
End
Begin VB.Label Label2
Caption = "说 明"
Height = 375
Left = 600
TabIndex = 2
Top = 1440
Width = 495
End
Begin VB.Label Label1
Caption = "类型名"
Height = 495
Left = 600
TabIndex = 1
Top = 480
Width = 975
End
End
End
Attribute VB_Name = "frmIType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private OK As Boolean '确定用户按了OK还是CANCEL按钮
Private m_obj As clsIType '数据对象,用来存贮用户输入数据
Public m_ViewType As gxcViewType '显示状态,指添加还是修改
'打开对对话框,并传入用户输入数据
Public Function ShowDlg(ByRef obj As Object, ByVal eViewType As gxcViewType) As Boolean
'保存数据
Set m_obj = obj '用户输入数据存放在此对象中
m_ViewType = eViewType '对话框状态
'根据新增、编辑或查看设置现实内容
SetStatus
'显示对话框
OK = False
Me.Show vbModal
If OK = False Then Exit Function
'保存数据
Set obj = m_obj
'返回并释放对话框
ShowDlg = True
Unload Me
End Function
'根据是新增、还是修改,确定显示内容
Private Sub SetStatus()
'设置控件默认值
Call SetDefaultvalue
'设置状态
Select Case m_ViewType
Case vtadd '添加
OKButton.Caption = "确定"
CancelButton.Visible = True
Case vtModify '修改
CancelButton.Visible = True
OKButton.Caption = "保存"
End Select
End Sub
'设置控件默认值
Private Sub SetDefaultvalue()
Dim ctl As Control
Dim i As Integer
'如果是新增,则清空所有文本框
'此处判断m_obj为空与判断m_viewtype=vtadd等效
If m_obj Is Nothing Then
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
End If
Next
Else '用传入对象的值更新数据
With m_obj
txtName.Text = .TypeName
txtRemark.Text = .Remark
End With
End If
End Sub
'确定按钮处理事件
Private Sub OKButton_Click()
OK = True
'检测输入的有效性
If Not CheckValid Then Exit Sub
'如果是新增状态,则初始化一个数据对象
If m_ViewType = vtadd Then Set m_obj = New clsIType
'保存用户输入
SaveValue
Me.Hide
End Sub
'检测输入有效性
Private Function CheckValid() As Boolean
If txtName.Text = "" Or txtRemark.Text = "" Then
MsgBox "请填写完毕以上各项内容"
CheckValid = False
Exit Function
End If
CheckValid = True
End Function
'保存数据
Private Sub SaveValue()
'给 成员变量 对象赋值
With m_obj
.TypeName = RealString(txtName.Text)
.Remark = RealString(txtRemark.Text)
End With
End Sub
'取消按钮处理事件
Private Sub CancelButton_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -