📄 sftimer
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.UserControl SFTIMER
ClientHeight = 285
ClientLeft = 0
ClientTop = 0
ClientWidth = 1605
ClipBehavior = 0 '无
DataBindingBehavior= 1 'vbSimpleBound
DataSourceBehavior= 1 'vbDataSource
MaskPicture = "Sftimer.ctx":0000
ScaleHeight = 285
ScaleWidth = 1605
ToolboxBitmap = "Sftimer.ctx":018A
Begin MSComCtl2.UpDown updHour
Height = 255
Left = 300
TabIndex = 3
Top = 0
Width = 270
_ExtentX = 476
_ExtentY = 450
_Version = 393216
Enabled = -1 'True
End
Begin VB.TextBox txtSecond
Height = 285
Left = 1080
MaxLength = 2
TabIndex = 2
TabStop = 0 'False
Text = "00"
Top = 0
Width = 300
End
Begin VB.TextBox txtMinute
Alignment = 1 'Right Justify
Height = 285
Left = 570
MaxLength = 2
TabIndex = 1
Text = "00"
Top = 0
Width = 300
End
Begin VB.TextBox txtHour
Alignment = 1 'Right Justify
Height = 285
Left = 0
MaxLength = 2
TabIndex = 0
Text = "00"
Top = 0
Width = 300
End
Begin MSComCtl2.UpDown updMinute
Height = 255
Left = 840
TabIndex = 4
Top = 0
Width = 270
_ExtentX = 476
_ExtentY = 450
_Version = 393216
Enabled = -1 'True
End
Begin MSComCtl2.UpDown updsecond
Height = 255
Left = 1320
TabIndex = 5
Top = 0
Width = 270
_ExtentX = 476
_ExtentY = 450
_Version = 393216
Enabled = -1 'True
End
End
Attribute VB_Name = "SFTIMER"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private Sub txtHour_Click()
SendKeys "{home}+{end}"
End Sub
Private Sub txtHour_GotFocus()
SendKeys "{home}+{end}"
End Sub
Private Sub txtHour_KeyDown(KeyCode As Integer, Shift As Integer)
' If KeyCode > 50 Then txtMinute.SetFocus
' If Val(txtHour.Text) <> 0 And Len(txtHour.Text) = 2 Then txtMinute.SetFocus
If KeyCode = 13 Then SendKeys vbTab
End Sub
Private Sub txtHour_KeyPress(KeyAscii As Integer)
'Is the value a number
If KeyAscii > 47 And KeyAscii < 58 Then
'Yes
Else
KeyAscii = 0
End If
End Sub
Private Sub txtHour_LostFocus()
'Is the value between 1-12
If Val(txtHour.Text) >= 0 And Val(txtHour.Text) < 24 Then
'Yes
Else
MsgBox "You must enter a value between 0-23", vbInformation & vbOKOnly, "Error:"
txtMinute.SetFocus
End If
End Sub
Private Sub txtMinute_Click()
SendKeys "{home}+{end}"
End Sub
Private Sub txtMinute_GotFocus()
SendKeys "{home}+{end}"
End Sub
Private Sub txtMinute_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
SendKeys vbTab
End If
End Sub
Private Sub txtMinute_KeyPress(KeyAscii As Integer)
If KeyAscii > 47 And KeyAscii < 58 Then
'Yes
Else
KeyAscii = 0
End If
End Sub
Private Sub txtMinute_LostFocus()
'Is the value between 0-59
If Val(txtMinute.Text) >= 0 And Val(txtMinute.Text) <= 59 Then
'Yes
Else
MsgBox "You must enter a value between 0-59", vbInformation & vbOKOnly, "Error:"
txtMinute.SetFocus
End If
End Sub
Private Sub txtSecond_KeyPress(KeyAscii As Integer)
If KeyAscii > 47 And KeyAscii < 58 Then
'Yes
Else
KeyAscii = 0
End If
End Sub
Private Sub txtSecond_LostFocus()
'Is the value between 0-59
If Val(txtSecond.Text) >= 0 And Val(txtSecond.Text) <= 59 Then
'Yes
Else
MsgBox "You must enter a value between 0-59", vbInformation & vbOKOnly, "Error:"
txtSecond.SetFocus
End If
End Sub
'Private Sub updAmPm_DownClick()
'
'If txtAmPm.Text = "AM" Then
' txtAmPm.Text = "PM"
'Else
' txtAmPm.Text = "AM"
'End If
'
'End Sub
'
'Private Sub updAmPm_UpClick()
'
'If txtAmPm.Text = "AM" Then
' txtAmPm.Text = "PM"
'Else
' txtAmPm.Text = "AM"
'End If
'
'End Sub
Private Sub updHour_DownClick()
If txtHour.Text = 1 Then
txtHour.Text = 23
Else
txtHour.Text = Format(txtHour.Text - 1, "0#")
End If
End Sub
Private Sub updHour_UpClick()
If txtHour.Text = 23 Then
txtHour.Text = Format(1, "0#")
Else
txtHour.Text = Format(txtHour.Text + 1, "0#")
End If
End Sub
Private Sub updMinute_DownClick()
If txtMinute.Text = 0 Then
txtMinute.Text = 59
Else
txtMinute.Text = Format(txtMinute.Text - 1, "0#")
End If
End Sub
Private Sub updMinute_UpClick()
If txtMinute.Text = 59 Then
txtMinute.Text = 0
Else
txtMinute.Text = Format(txtMinute.Text + 1, "0#")
End If
End Sub
Private Sub updSecond_DownClick()
If txtSecond.Text = 0 Then
txtSecond.Text = 59
Else
txtSecond.Text = Format(txtSecond.Text - 1, "0#")
End If
End Sub
Private Sub updSecond_UpClick()
If txtSecond.Text = 59 Then
txtSecond.Text = 0
Else
txtSecond.Text = Format(txtSecond.Text + 1, "0#")
End If
End Sub
Public Property Get Text() As Date
Text = Format(txtHour & ":" & txtMinute & ":" & txtSecond, "hh:mm:ss")
End Property
Public Property Let Text(dTime As Date)
txtHour = Format(dTime, "hh") '''Mid$(Format(dTime, "hha/p"), 1, 2)
txtMinute = Format(dTime, "nn")
txtSecond = Format(dTime, "Ss")
End Property
Public Property Get Text2() As Date
Text2 = Format(txtHour & ":" & txtMinute, "hh:mm")
End Property
Public Property Let Text2(dTime As Date)
txtHour = Format(dTime, "hh") '''Mid$(Format(dTime, "hha/p"), 1, 2)
txtMinute = Format(dTime, "nn")
txtSecond = Format(dTime, "Ss")
End Property
Private Sub UserControl_GotFocus()
txtHour.SetFocus
End Sub
Private Sub UserControl_Initialize()
'txtHour.SetFocus
End Sub
Private Sub UserControl_Resize()
If UserControl.width < 1230 Then
UserControl.width = 1230
'txtHour.Width = 250
'txtMinute.Width = 250
'txtSecond.Width = 250
'updHour.Left = 250
'txtMinute.Left = 490
'txtSecond.Left = 740
'updsecond.Left = 980
'updsecond.Left = 1230
Exit Sub
Else
txtHour.width = (UserControl.width - 720) \ 3
txtMinute.width = txtHour.width
txtSecond.width = txtHour.width
updHour.Left = txtHour.width
txtMinute.Left = txtHour.width + 240
updMinute.Left = txtHour.width * 2 + 240
txtSecond.Left = txtHour.width * 2 + 480
updsecond.Left = txtHour.width * 3 + 480
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -