?? frmmtype.frm
字號:
VERSION 5.00
Begin VB.Form frmMType
BorderStyle = 3 'Fixed Dialog
Caption = "商品類型信息"
ClientHeight = 3180
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 5655
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3180
ScaleWidth = 5655
ShowInTaskbar = 0 'False
Begin VB.Frame fraMerchType
Caption = "商品類型信息"
Height = 2175
Left = 240
TabIndex = 4
Top = 240
Width = 5055
Begin VB.TextBox txtName
Height = 375
Left = 1200
MaxLength = 18
TabIndex = 0
Text = "txtName"
Top = 263
Width = 2535
End
Begin VB.TextBox txtRemark
Height = 1215
Left = 1200
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Text = "frmMType.frx":0000
Top = 840
Width = 3735
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "說明"
Height = 180
Left = 360
TabIndex = 6
Top = 840
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "類型名"
Height = 180
Left = 360
TabIndex = 5
Top = 360
Width = 540
End
End
Begin VB.CommandButton CancelButton
Caption = "取消"
Height = 330
Left = 4200
TabIndex = 3
Top = 2640
Width = 1215
End
Begin VB.CommandButton OKButton
Caption = "確定"
Height = 330
Left = 2760
TabIndex = 2
Top = 2640
Width = 1215
End
End
Attribute VB_Name = "frmMType"
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 clsMType '數(shù)據(jù)對象,用來存儲用戶輸入數(shù)據(jù)
Public m_ViewType As gxcViewType '顯示狀態(tài),指添加還是修改
'根據(jù)是“新增”還是“修改”,確定顯示內(nèi)容
Private Sub SetStatus()
'設(shè)置控件默認(rèn)值
Call SetDefaultValue
'設(shè)置狀態(tài)
Select Case m_ViewType
Case vtadd '添加
CancelButton.Visible = True
OKButton.Caption = "確定"
Case vtModify '修改
CancelButton.Visible = True
OKButton.Caption = "保存"
End Select
End Sub
'打開對話框,并傳出用戶輸入數(shù)據(jù)
Public Function ShowDlg(ByRef obj As Object, _
ByVal eViewType As gxcViewType _
) As Boolean
'保存數(shù)據(jù)
Set m_obj = obj '用戶輸入數(shù)據(jù)存放于此對象中
m_ViewType = eViewType '對話框狀態(tài)
'根據(jù)新增、編輯或查看設(shè)置顯示內(nèi)容
SetStatus
'顯示對話框
OK = False
Me.Show vbModal
If OK = False Then Exit Function
'保存數(shù)據(jù)
Set obj = m_obj
'返回并釋放對話框
ShowDlg = True
Unload Me
End Function
'設(shè)置控件默認(rèn)值
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 '用傳入對象的值更新數(shù)據(jù)
With m_obj
txtName.Text = .TypeName
txtRemark.Text = .Remark
End With
End If
End Sub
'檢查輸入有效性
Private Function CheckValid() As Boolean
If txtName.Text = "" _
Or txtRemark.Text = "" Then
MsgBox "請?zhí)顚懲戤呉陨细黜梼?nèi)容"
CheckValid = False
Exit Function
End If
CheckValid = True
End Function
'保存數(shù)據(jù)
Private Sub SaveValue()
'給“成員變量”對象賦值
With m_obj
'注意以下利用RealString函數(shù)替換去除輸入中的單引號
.TypeName = RealString(txtName.Text)
.Remark = RealString(txtRemark.Text)
End With
End Sub
'取消按鈕
Private Sub CancelButton_Click()
Unload Me
End Sub
'確定按鈕
Private Sub OKButton_Click()
OK = True
'檢測輸入有效性
If Not CheckValid Then Exit Sub
'如果是新增狀態(tài),則初始化一個數(shù)據(jù)對象
If m_ViewType = vtadd Then Set m_obj = New clsMType
'保存用戶輸入
SaveValue
Me.Hide
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -