¦U¦ì¤j¤j¡A½Ð°ÝUserFormªí³æ¦p¦óŪ¨ú¤lªí³æ
- ©«¤l
- 12
- ¥DÃD
- 0
- ºëµØ
- 0
- ¿n¤À
- 62
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- office 365
- ¾\ŪÅv
- 20
- ©Ê§O
- ¤k
- µù¥U®É¶¡
- 2022-2-1
- ³Ì«áµn¿ý
- 2022-12-29
|
¥»©«³Ì«á¥Ñ lee88 ©ó 2022-12-26 15:17 ½s¿è
¦^´_ 6# wsx1130
¾ã²z¤@¤Uµ{¦¡½X
UserForm1ªºµ{¦¡½X- Option Explicit
- Private Sub UserForm_Initialize()
- With TextBox1
- .Width = 100
- .Font.Size = 12
- .Font.Bold = True
- End With
- End Sub
- Private Sub UserForm_Activate()
- If UserForm2.Visible = False Then MsgBox "«ö¤Uªí³æ ©I¥s ¤é´Áªí³æ"
- End Sub
- Private Sub UserForm_Click()
- If UserForm2.Visible = False Then UserForm2.Show 0
- End Sub
- Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
- If UserForm2.Visible = True Then Unload UserForm2
- End Sub
½Æ»s¥N½X UserForm1ªºµ{¦¡½X- Option Explicit
- Public Thisday As Date
- Dim CreateCal As Boolean, i As Integer
- Dim Form_Button(1 To 42) As New Class1 '·sªºª«¥ó¼Ò²Õ
- Private Sub UserForm_Initialize()
- Thisday = Date
- For i = 1 To 12
- CB_Mth.AddItem Format(DateSerial(Year(Thisday), i, 1), "m¤ë mmmm")
- Next
- CB_Mth.Value = CB_Mth.List(Month(Thisday) - 1)
- For i = 1980 To 2099 ' PC¤º«Ø¤é´Á¦~«×
- CB_Yr.AddItem i
- Next
- CB_Yr.Value = Year(Thisday)
- Make_com
- CreateCal = True
- Call Build_Calendar
- Application.EnableEvents = True
- End Sub
- Sub Make_com()
- For i = 1 To 42
- Set Form_Button(i).C_Button = Controls("d" & i) '±Nªí³æªº±±¨î¶µ ¾É¤J¬°ª«¥ó¼Ò²Õªº±±¨î¶µ
- Next
- End Sub
- Private Sub CB_Mth_Change()
- 'rebuilds the calendar when the month is changed by the user
- Build_Calendar
- End Sub
- Private Sub CB_Yr_Change()
- 'rebuilds the calendar when the year is changed by the user
- Build_Calendar
- End Sub
- Private Sub Build_Calendar()
- 'the routine that actually builds the calendar each time
- Dim S_Day As Date, Msg As Boolean
- If CreateCal = False Then Exit Sub
- UserForm2.Caption = " " & CB_Mth.Value & " " & CB_Yr.Value
- S_Day = DateSerial(CB_Yr, CB_Mth.ListIndex + 1, 1) - Weekday(DateSerial(CB_Yr, CB_Mth.ListIndex + 1, 1), vbMonday)
- 'S_Day = 42Ó«öÁ䪺²Ä¤@¤Ñ
- For i = 1 To 42
- Msg = Month(S_Day + i - 1) = CB_Mth.ListIndex + 1
- With Controls("d" & i)
- .ControlTipText = S_Day + i - 1
- .Caption = Day(S_Day + i - 1) '«ü©w¤é´Á
- .Font.Bold = Msg ' True '<-©w²ÊÅé
- .ForeColor = IIf(Msg, vbBlack, vbWhite) 'Fc '¦rÅéÃC¦â
- .ForeColor = IIf(Weekday(.ControlTipText) > 6 Or Weekday(.ControlTipText) = 1, vbRed, IIf(Msg, vbBlack, vbWhite))
- .BackColor = IIf(Msg, vbCyan, vbBlack) 'I´ºÃC¦â
- End With
- Next
- End Sub
- Private Sub UserForm_RemoveControl(ByVal Control As MSForms.Control)
- Unload Me
- End Sub
½Æ»s¥N½X **¶·¦b±M®×µøµ¡¥[¤W¤@Ó ª«¥óÃþ§O¼Ò²Õ ·|¦Û°Ê©R¦W¬°Class1(¦WºÙ¥iקï)
Class1ªºµ{¦¡½X- Option Explicit
- Public WithEvents C_Button As MSForms.CommandButton
- Private Sub C_Button_Click()
- With C_Button.Parent.Parent.Parent
- ' 42Ó«öÁ䪺.Parent = Frame1->Frame1.Parent=.Frame2->Frame2.Parent=UserForm2
- .Thisday = C_Button.ControlTipText
- UserForm1.TextBox1 = .Thisday
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|