📄 ymddate.ctl
字号:
VERSION 5.00
Begin VB.UserControl YMDDate
ClientHeight = 315
ClientLeft = 0
ClientTop = 0
ClientWidth = 3405
ScaleHeight = 315
ScaleWidth = 3405
Begin VB.ComboBox cboNyD
Height = 300
Left = 2400
TabIndex = 4
Text = "cboNyD"
Top = 0
Width = 615
End
Begin VB.ComboBox cboNyM
Height = 300
Left = 1440
TabIndex = 2
Text = "cboNyM"
Top = 0
Width = 615
End
Begin VB.ComboBox cboNyY
Height = 300
Left = 120
TabIndex = 0
Text = "cboNyY"
Top = 0
Width = 855
End
Begin VB.Label Label3
Caption = "日"
Height = 255
Left = 3120
TabIndex = 5
Top = 120
Width = 255
End
Begin VB.Label Label2
Caption = "月"
Height = 255
Left = 2160
TabIndex = 3
Top = 120
Width = 255
End
Begin VB.Label Label1
Caption = "年"
Height = 255
Left = 1080
TabIndex = 1
Top = 120
Width = 495
End
End
Attribute VB_Name = "YMDDate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'****************************************************************************
'人人为我,我为人人
'枕善居收藏整理
'发布日期:2007/09/25
'描 述:江苏大学网络信息中心网络管理系统 - v1.0 Beta
'网 站:http://www.Mndsoft.com/ (VB6源码博客)
'网 站:http://www.VbDnet.com/ (VB.NET源码博客,主要基于.NET2005)
'e-mail :Mndsoft@163.com
'e-mail :Mndsoft@126.com
'OICQ :88382850
' 如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************
Private Sub cboNyM_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
Else
If KeyAscii <> 8 And Len(Trim(cboNyM.Text)) = 2 Then
KeyAscii = 0
End If
End If
End Sub
Private Sub cboNyY_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
Else
If KeyAscii <> 8 And Len(Trim(cboNyY.Text)) = 4 Then
KeyAscii = 0
End If
End If
End Sub
Private Sub cboNyD_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
Else
If KeyAscii <> 8 And Len(Trim(cboNyD.Text)) = 2 Then
KeyAscii = 0
End If
End If
End Sub
'Private Sub cboNyY_KeyPress(KeyAscii As Integer)
'If Len(Trim(cboNyY.Text)) = 5 Then
' cboNyY.Text = Left(Trim(cboNyY.Text), 4)
'End If
'End Sub
Private Sub UserControl_Initialize()
'出生年月 年
For j = CInt(Year(Now())) To CInt(Year(Now())) - 100 Step -1
cboNyY.AddItem j
Next j
cboNyY.Text = ""
'出生年月 月
For j = 1 To 12
cboNyM.AddItem Format(j, "00")
Next j
cboNyM.Text = ""
'出生年月 日
For j = 1 To 31
cboNyD.AddItem Format(j, "00")
Next j
cboNyD.Text = ""
End Sub
Public Property Let Enabled(ByVal b As Boolean)
If b = True Then
cboNyY.Enabled = True
cboNyM.Enabled = True
cboNyD.Enabled = True
ElseIf b = False Then
cboNyY.Enabled = False
cboNyM.Enabled = False
cboNyD.Enabled = False
End If
End Property
Public Property Get FormatDate() As String
Dim NyY As String
Dim NyM As String
Dim NyD As String
If cboNyY.Text = "" And cboNyM.Text = "" And cboNyD.Text = "" Then
FormatDate = ""
Exit Sub
End If
If cboNyY.Text = "" Then
NyY = CStr(Year(Now()))
Else
NyY = cboNyY.Text
End If
If cboNyM.Text = "" Then
NyM = "1"
Else
NyM = cboNyM.Text
End If
If cboNyD.Text = "" Then
NyD = "1"
Else
NyD = cboNyD.Text
End If
FormatDate = NyY + "-" + NyM + "-" + NyD
End Property
Public Property Let FormatDate(ByVal txt As String)
If txt <> "" Then
'cboNyY.Text = Left(txt, 4)
cboNyY.Text = Year(txt)
'z1 = InStr(1, txt, "/", 0)
'cboNyM.Text = Mid(txt, z1 + 1)
cboNyM.Text = Format(Month(txt), "00")
'z2 = InStr(z1 + 1, txt, "/", 0)
'cboNyD.Text = Mid(txt, z2 + 1)
cboNyD.Text = Format(Day(txt), "00")
PropertyChanged "FormatDate"
Else
cboNyY.Clear
'出生年月 年
For j = CInt(Year(Now())) To CInt(Year(Now())) - 100 Step -1
cboNyY.AddItem j
Next j
'cboNyY.Text = Year(Now())
cboNyY.Text = ""
cboNyM.Clear
'出生年月 月
For j = 1 To 12
cboNyM.AddItem Format(j, "00")
Next j
' cboNyM.Text = Month(Now())
cboNyM.Text = ""
'出生年月 日
For j = 1 To 31
cboNyD.AddItem Format(j, "00")
Next j
'cboNyD.Text = Day(Now())
cboNyD.Text = ""
End If
End Property
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -