|
主要改了类模块的输出接口
Private Sub buttonGroup_Click() 'ÈÕÆÚ°´Å¥ ʼþ Àà
Dim Y, m As Integer
If Len(buttonGroup.Caption) = 0 Then Exit Sub
With CalendarForm
Y = Val(.ComboBoxY.Value) 'È¥µôÓұߵÄ"Äê"
m = Val(.ComboBoxM.Value)
If Y < 1901 Then
MsgBox "Äê·Ý²»ÄÜСÓÚ1901,ÇëÖØÐÂÊäÈ룡" 'Excel¼Ù¶¨1900ÄêÊÇÈòÄ꣬ÕâÊÇ´íÎóµÄ¡£
.ComboBoxY.SetFocus
Exit Sub
End If
End With
On Error Resume Next
If Len(buttonGroup.Tag) = 0 Then
Thehide.Cells(35, 1).Value = DateSerial(Y, m, buttonGroup.Caption) '¸³Öµ¸ø¿ªÊ¼ÈÕÆÚ£¨Äê-ÔÂ-ÈÕ£© ‘输出到一个单元格
Else
Thehide.Cells(35, 1).Value = DateSerial(Y, Val(buttonGroup.Tag), buttonGroup.Caption) ' ²»ÊDZ¾Ô ¸³Öµ¸ø¿ªÊ¼ÈÕÆÚ£¨Äê-ÔÂ-ÈÕ£©
End If
CalendarForm.Hide
On Error GoTo 0
End Sub
‘所有结果均输出到同一单元格’
‘然后自己写了一个单元格的变化触发输出到不同的文本框控件的程序’
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 35 And Target.Column = 1 Then
If Thehide.Cells(35, 3).Value = "Pg2form" And Thehide.Cells(35, 2).Value = "DTPISL1" Then
Pg2form.DTPISL1.Value = Target.Value
ElseIf Thehide.Cells(35, 3).Value = "Pg2form" And Thehide.Cells(35, 2).Value = "DTPISL2" Then
Pg2form.DTPISL2.Value = Target.Value
ElseIf Thehide.Cells(35, 3).Value = "Pg2form" And Thehide.Cells(35, 2).Value = "DTPISL3" Then
Pg2form.DTPISL3.Value = Target.Value
ElseIf Thehide.Cells(35, 3).Value = "Pg2form" And Thehide.Cells(35, 2).Value = "DTPISL4" Then
Pg2form.DTPISL4.Value = Target.Value
ElseIf Thehide.Cells(35, 3).Value = "Pg2form" And Thehide.Cells(35, 2).Value = "DTPISL5" Then
Pg2form.DTPISL5.Value = Target.Value
ElseIf Thehide.Cells(35, 3).Value = "Pg2form" And Thehide.Cells(35, 2).Value = "DTPISL6" Then
Pg2form.DTPISL6.Value = Target.Value
ElseIf Thehide.Cells(35, 3).Value = "Pg6form" And Thehide.Cells(35, 2).Value = "DTPISL2" Then
Pg6form.DTPISL2.Value = Target.Value
ElseIf Thehide.Cells(35, 3).Value = "Pg7form" And Thehide.Cells(35, 2).Value = "DTPISL1" Then
Pg7form.DTPISL1.Value = Target.Value
ElseIf Thehide.Cells(35, 3).Value = "Pg7form" And Thehide.Cells(35, 2).Value = "DTPISL2" Then
Pg7form.DTPISL2.Value = Target.Value
ElseIf Thehide.Cells(35, 3).Value = "Pg7form" And Thehide.Cells(35, 2).Value = "DTPISL3" Then
Pg7form.DTPISL3.Value = Target.Value
ElseIf Thehide.Cells(35, 3).Value = "Pg7form" And Thehide.Cells(35, 2).Value = "DTPpayment" Then
Pg7form.DTPpayment.Value = Target.Value
End If
End If
End Sub
这样就完美的用一个日历窗体解决了很多个日期控件的问题,表现得跟DTPicker一样。 |
评分
-
3
查看全部评分
-
|