ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

¦U¦ì¤j¤j¡A½Ð°ÝUserFormªí³æ¦p¦óŪ¨ú¤lªí³æ

¥»©«³Ì«á¥Ñ lee88 ©ó 2022-12-26 15:17 ½s¿è

¦^´_ 6# wsx1130
¾ã²z¤@¤Uµ{¦¡½X
UserForm1ªºµ{¦¡½X
  1. Option Explicit
  2. Private Sub UserForm_Initialize()
  3.     With TextBox1
  4.         .Width = 100
  5.         .Font.Size = 12
  6.         .Font.Bold = True
  7.     End With
  8. End Sub
  9. Private Sub UserForm_Activate()
  10.   If UserForm2.Visible = False Then MsgBox "«ö¤Uªí³æ  ©I¥s ¤é´Áªí³æ"
  11. End Sub
  12. Private Sub UserForm_Click()
  13.   If UserForm2.Visible = False Then UserForm2.Show 0
  14. End Sub
  15. Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
  16.     If UserForm2.Visible = True Then Unload UserForm2
  17. End Sub
½Æ»s¥N½X
UserForm1ªºµ{¦¡½X
  1.   Option Explicit
  2.     Public Thisday As Date
  3.     Dim CreateCal As Boolean, i As Integer
  4.     Dim Form_Button(1 To 42) As New Class1 '·sªºª«¥ó¼Ò²Õ
  5. Private Sub UserForm_Initialize()
  6.     Thisday = Date
  7.     For i = 1 To 12
  8.         CB_Mth.AddItem Format(DateSerial(Year(Thisday), i, 1), "m¤ë  mmmm")
  9.     Next
  10.     CB_Mth.Value = CB_Mth.List(Month(Thisday) - 1)
  11.     For i = 1980 To 2099 ' PC¤º«Ø¤é´Á¦~«×
  12.         CB_Yr.AddItem i
  13.     Next
  14.     CB_Yr.Value = Year(Thisday)
  15.     Make_com
  16.     CreateCal = True
  17.     Call Build_Calendar
  18.     Application.EnableEvents = True
  19. End Sub
  20. Sub Make_com()
  21.     For i = 1 To 42
  22.        Set Form_Button(i).C_Button = Controls("d" & i)   '±Nªí³æªº±±¨î¶µ ¾É¤J¬°ª«¥ó¼Ò²Õªº±±¨î¶µ
  23.     Next
  24. End Sub
  25. Private Sub CB_Mth_Change()
  26.     'rebuilds the calendar when the month is changed by the user
  27.     Build_Calendar
  28. End Sub
  29. Private Sub CB_Yr_Change()
  30.     'rebuilds the calendar when the year is changed by the user
  31.     Build_Calendar
  32. End Sub
  33. Private Sub Build_Calendar()
  34.     'the routine that actually builds the calendar each time
  35.     Dim S_Day As Date, Msg As Boolean
  36.     If CreateCal = False Then Exit Sub
  37.     UserForm2.Caption = " " & CB_Mth.Value & " " & CB_Yr.Value
  38.     S_Day = DateSerial(CB_Yr, CB_Mth.ListIndex + 1, 1) - Weekday(DateSerial(CB_Yr, CB_Mth.ListIndex + 1, 1), vbMonday)
  39.     'S_Day =  42­Ó«öÁ䪺²Ä¤@¤Ñ
  40.     For i = 1 To 42
  41.         Msg = Month(S_Day + i - 1) = CB_Mth.ListIndex + 1
  42.         With Controls("d" & i)
  43.                 .ControlTipText = S_Day + i - 1
  44.                 .Caption = Day(S_Day + i - 1)            '«ü©w¤é´Á
  45.                 .Font.Bold = Msg ' True                    '<-©w²ÊÅé
  46.                 .ForeColor = IIf(Msg, vbBlack, vbWhite) 'Fc '¦rÅéÃC¦â
  47.                 .ForeColor = IIf(Weekday(.ControlTipText) > 6 Or Weekday(.ControlTipText) = 1, vbRed, IIf(Msg, vbBlack, vbWhite))
  48.                 .BackColor = IIf(Msg, vbCyan, vbBlack)              '­I´ºÃC¦â
  49.         End With
  50.     Next
  51. End Sub
  52. Private Sub UserForm_RemoveControl(ByVal Control As MSForms.Control)
  53.     Unload Me
  54. End Sub
½Æ»s¥N½X
**¶·¦b±M®×µøµ¡¥[¤W¤@­Ó ª«¥óÃþ§O¼Ò²Õ ·|¦Û°Ê©R¦W¬°Class1(¦WºÙ¥i­×§ï)
Class1ªºµ{¦¡½X
  1. Option Explicit
  2. Public WithEvents C_Button    As MSForms.CommandButton
  3. Private Sub C_Button_Click()
  4.         With C_Button.Parent.Parent.Parent
  5.             ' 42­Ó«öÁ䪺.Parent = Frame1->Frame1.Parent=.Frame2->Frame2.Parent=UserForm2
  6.             .Thisday = C_Button.ControlTipText
  7.             UserForm1.TextBox1 = .Thisday
  8.         End With
  9. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : §Ú­Ì­n°µ¦nªÀ·|ªºÀô«O¡A¤]­n°µ¦n¤º¤ßªºÀô«O¡C
ªð¦^¦Cªí ¤W¤@¥DÃD