📄 dlgxys.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{0B81E4A9-BE4E-4AEF-9272-33AB5B51C6FC}#1.0#0"; "XPControls.ocx"
Begin VB.Form dlgXYS
BackColor = &H80000018&
BorderStyle = 3 'Fixed Dialog
Caption = "吸烟史"
ClientHeight = 4005
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 4695
Icon = "dlgXYS.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4005
ScaleWidth = 4695
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.TextBox txtNumber
Height = 285
Left = 1530
TabIndex = 4
Top = 690
Width = 645
End
Begin VB.TextBox txtDescription
Height = 1095
Left = 1530
TabIndex = 3
Top = 1200
Width = 2385
End
Begin XPControls.XPCommandButton cmdCancel
Height = 375
Left = 2700
TabIndex = 0
Top = 3270
Width = 975
_ExtentX = 1720
_ExtentY = 661
Caption = "取消(&C)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdOK
Height = 375
Left = 1140
TabIndex = 1
Top = 3270
Width = 975
_ExtentX = 1720
_ExtentY = 661
Caption = "确定(&O)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSComCtl2.DTPicker dtpStop
Height = 315
Left = 1530
TabIndex = 2
Top = 2490
Width = 1365
_ExtentX = 2408
_ExtentY = 556
_Version = 393216
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Format = 61734913
CurrentDate = 38037
End
Begin MSComCtl2.DTPicker dtpBegin
Height = 315
Left = 1530
TabIndex = 5
Top = 210
Width = 1365
_ExtentX = 2408
_ExtentY = 556
_Version = 393216
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Format = 61734913
CurrentDate = 38037
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "开始时间:"
Height = 225
Left = 450
TabIndex = 10
Top = 270
Width = 1035
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "吸烟量:"
Height = 225
Left = 450
TabIndex = 9
Top = 750
Width = 1035
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "支/天"
Height = 225
Left = 2310
TabIndex = 8
Top = 750
Width = 555
End
Begin VB.Label Label4
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "情况描述:"
Height = 225
Left = 450
TabIndex = 7
Top = 1200
Width = 1035
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "戒断时间:"
Height = 225
Left = 450
TabIndex = 6
Top = 2580
Width = 1035
End
End
Attribute VB_Name = "dlgXYS"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mblnOK As Boolean '用户单击了哪个按钮
Dim mstrRet As String
Dim menuOperation As OperationType
Private Sub cmdCancel_Click()
mblnOK = False
Unload Me
End Sub
'被FrmQuery_C调用的函数
Public Function ShowXYS(ByVal enuOperation As OperationType, Optional ByVal strXYS As String) As String
On Error GoTo ErrMsg
Dim Status
Dim arrXYS
menuOperation = enuOperation
'判断是否更新
If enuOperation = Modify Then
arrXYS = Split(strXYS, JoinSymbol)
dtpBegin.Value = arrXYS(0)
txtNumber.Text = arrXYS(1)
txtDescription.Text = arrXYS(2)
dtpStop.Value = arrXYS(3)
End If
'显示窗体
Me.Show vbModal
'查看返回值
If mblnOK = True Then
ShowXYS = mstrRet
End If
Exit Function
ErrMsg:
End Function
Private Sub cmdOK_Click()
Dim itmXYS As ListItem
'校验用户输入的合法性
'开始时间
If dtpBegin.Value > Date Then
MsgBox "您输入的开始时间不符合实际情况,请重新输入!", vbInformation, "提示"
dtpBegin.SetFocus
Exit Sub
End If
'戒断时间
If dtpStop.Value > Date Then
MsgBox "您输入的戒断时间不符合实际情况,请重新输入!", vbInformation, "提示"
dtpStop.SetFocus
Exit Sub
End If
'开始时间是否在戒断时间前面
If dtpBegin.Value > dtpStop.Value Then
MsgBox "开始时间不应该比戒断时间迟!请重新输入!", vbInformation, "提示"
dtpBegin.SetFocus
Exit Sub
End If
'吸烟量
If Val(txtNumber.Text) <= 0 Then
MsgBox "吸烟量应该是非负数!请重新输入!", vbInformation, "提示"
txtNumber.SetFocus
Exit Sub
End If
'校验完毕
mblnOK = True
mstrRet = dtpBegin.Value & JoinSymbol _
& txtNumber.Text & JoinSymbol _
& txtDescription.Text & JoinSymbol _
& dtpStop.Value
Unload Me
End Sub
Private Sub dtpBegin_KeyPress(KeyAscii As Integer)
EnterToTab KeyAscii
End Sub
Private Sub dtpStop_KeyPress(KeyAscii As Integer)
EnterToTab KeyAscii
End Sub
Private Sub txtNumber_KeyPress(KeyAscii As Integer)
'不是回车和退格键的时候,校验长度和字符
If (KeyAscii <> vbKeyBack) And (KeyAscii <> vbKeyReturn) Then
'是否输入了数字
If (KeyAscii < vbKey0) Or (KeyAscii > vbKey9) Then
Beep 50, 10
KeyAscii = 0
End If
'校验长度
If Len(txtNumber.Text) >= 3 Then
MsgBox "最大只能输入999!", vbInformation, "提示"
KeyAscii = 0
Exit Sub
End If
End If
EnterToTab KeyAscii
End Sub
Private Sub txtNumber_LostFocus()
txtNumber.Text = Val(txtNumber.Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -