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

§Q¥ÎVBA ªí³æ»s§@¸U¦~¾ä?

¦^´_ 9# Jared

§A³o°ÝÃD¦³¥i¯à¬O ´`Àô¤º §A§Ë¿ù°Ñ¼Æ..

¨Ò¦p
k=1
for hwe = 1 to 31

    me.controls("optionbutton"& hwe ) = hwe

next

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

TOP

¦^´_ 9# Jared
  1. ³o­Ó¤ëªº²Ä¤@¤Ñ    DateSerial(ComboBox1, ComboBox2, 1)
  2. ³o­Ó¤ëªº³Ì«á¤@¤Ñ DateSerial(ComboBox1, ComboBox2.Value + 1, 0)
½Æ»s¥N½X
­×§ï 5# ÀÉ®× ªí³æµ{¦¡½X ¦p¤U
  1. Option Explicit
  2. Dim Class_OB(1 To 7, 1 To 6) As New Class1
  3. Private Sub UserForm_Initialize()
  4.     Dim I As Integer
  5.      ¤é´Á¶µ
  6.     For I = 1980 To 2099
  7.         ComboBox1.AddItem I
  8.     Next
  9.     ComboBox1.Value = Year(Date)
  10.     For I = 1 To 12
  11.         ComboBox2.AddItem I
  12.     Next
  13.     ComboBox2.Value = Month(Date)
  14. End Sub
  15. Private Sub ComboBox1_Change()
  16.     ¤ë¾ä
  17. End Sub
  18. Private Sub ComboBox2_Change()
  19.     ¤ë¾ä
  20. End Sub
  21. Private Sub ¤ë¾ä()
  22.    ¤ë¾ä²M°£
  23.     If ComboBox1.ListIndex > -1 And ComboBox2.ListIndex > -1 Then ¸U¦~¾ä
  24. End Sub
  25. Private Sub ¸U¦~¾ä()
  26.     Dim R As Integer, I As Date, WD As Integer
  27.      R = 1
  28.      For I = DateSerial(ComboBox1, ComboBox2, 1) To DateSerial(ComboBox1, ComboBox2.Value + 1, 0)
  29.         WD = Weekday(I)
  30.         With Controls(R & "_" & WD)
  31.             .Enabled = True
  32.             .Caption = Day(I)
  33.             .ControlTipText = I
  34.         End With
  35.         If WD = 7 Then R = R + 1
  36.      Next
  37. End Sub
  38. Private Sub ¤é´Á¶µ()
  39.     Dim OBtop As Integer, OBLeft As Integer, R As Integer
  40.     Dim OB_1 As Integer, OB_2 As Integer
  41.     R = Label1.Top + 30
  42.       For OB_2 = 1 To UBound(Class_OB, 2)
  43.         For OB_1 = 1 To UBound(Class_OB, 1)
  44.             With Controls.Add("Forms.OptionButton.1", OB_2 & "_" & OB_1)
  45.                 .Visible = True
  46.                 .Top = R '
  47.                 .Left = Controls("Label" & OB_1).Left
  48.                 'Controls("Label" & OB_1)->¤w«Ø¥ß¬P´Á¤§ Label±±¨î¶µ
  49.                 '¦WºÙ¨Ì§Ç¬°Label1,Label2,Label3,Label4,Label5,Label6,Label7.
  50.                 .Height = 15
  51.                 .Width = 30
  52.                 .ControlTipText = ""
  53.             End With
  54.             Set Class_OB(OB_1, OB_2).OB = Controls(OB_2 & "_" & OB_1)
  55.         Next
  56.         R = R + 30
  57.      Next
  58. End Sub
  59. Private Sub ¤ë¾ä²M°£()
  60.     Dim E As Control
  61.     For Each E In Me.Controls
  62.         If E.Name Like "*_*" Then
  63.             E.Enabled = False
  64.             E.Caption = ""
  65.             E.ControlTipText = ""
  66.         End If
  67.     Next
  68. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 11# mark15jill


¤j¤j
«á¨Óµo²{¹Bºâ¦¡³£¿ù¤F
­pºâ¥X¨Óªº¤Ñ¼Æ³£¤£¹ï....><
Jared

TOP

¦^´_ 12# GBKEE


    ·Q½Ð°Ý¤@¤U¤j¤j
    µ{¦¡¤¤·í§ÚÂI¿ï¤é´Áªº®É­Ô
    ·|¸õ¥Xĵ§iµøµ¡
    §iª¾§AÂI¿ïªº¬O¦~¤ë¤é

    ¨º¦pªG¬O­nÂI¿ï¤é´Á«á´N°Ê§@
    ª½±µ¼g¤J«ü©wÄæ¦ì¬O­n¦b­þ¸Ì¼¶¼g©O¡H(¨Ò¦p¡GSheet1.Range("A1"))
¡@¥Ñ©óªí³æ­¶­±¤WªºOptionButton³£¬OÁôÂêº
    ¦]¦¹§Ú²K¥[µ{¦¡¤£¾å±o¼g­þ¸Ì
   
    §Æ±æ¤j¤j¸Ñ°£§ÚªººÃ´b
    ·P¿E¤£ºÉ¡I><
Jared

TOP

¦^´_ 14# Jared
ª«¥óÃþ§O¼Ò²Õ Class1
  1. Option Explicit
  2. Public WithEvents OB As MSForms.OptionButton
  3. Private Sub OB_Click()
  4.     'MsgBox OB.Caption
  5.     '¦~¤ë¤é
  6.     Sheet1.[a1] = OB.ControlTipText
  7.     '¤é´Á
  8.     'Sheet1.[a1] = OB.Caption
  9. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 15# GBKEE


    ·PÁ¤j¤j¸Ñ¶}§ÚªººÃ´b
    ­ì¨Ó§Ú§Ë¿ù¦a¤è¤F
    ¨Sª`·N¨ìClass ª«¥óÃþ§O¼Ò²Õ¸Ì­±ªºµ{¦¡½X
    ·d¤£À´ OB¬O¤°»ò·N«ä

    ­è­è¬O·Q¦b
    With Controls.Add("Forms.OptionButton.1", I) ¸Ì­±¥[¤J
    If .Visible = True Then
    Sheet1.Range("A1") = DateSerial(ComboBox1, ComboBox2, Day(I))
    End If
   
    ¦ý­ì¥»ªí³æ¤W­±´N¨S¦³¥X²{OptionButton
    ©Ò¥H¤Ñ¼Æ¨º¸Ì¤]¤£¾å±o«ç»ò¥Î
    ²{¦b§Úª¾¹D¤F

    ¤£¹L¬Ý¨Ó§ÚÁÙ­nÄ~Äò¥[ªo¤F...><
Jared

TOP

¦^´_  mark15jill


¤j¤j
«á¨Óµo²{¹Bºâ¦¡³£¿ù¤F
­pºâ¥X¨Óªº¤Ñ¼Æ³£¤£¹ï....>
Jared µoªí©ó 2013-3-26 14:09



Ãö©ó¤Ñ¼Æ
³o­Ó§Ú«á¨Ó¦³µo²{
¦Ó¥B¯«©_ªº¬O....

§Ú¥ÎVB.NET ©MVBA  ¥Î¦P ­pºâ¦¡¥h¶]..
µ²ªGVB.NET §¹¥þ¥¿½T..
VBA·|²ö¦W¨ä§®¿ù¶Ã..<¤Ñ¼Æ¹ï  ¬P´Á¿ù¶Ã>

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

TOP

¦^´_ 17# mark15jill
   
<¤Ñ¼Æ¹ï  ¬P´Á¿ù¶Ã>
¬P´Á¿ù¶Ã: §A¬O¥Î¦ó¨ç¼Æ
¶Ç¤Wµ{¦¡½X¬Ý¬Ý
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  mark15jill
     ¬P´Á¿ù¶Ã: §A¬O¥Î¦ó¨ç¼Æ
¶Ç¤Wµ{¦¡½X¬Ý¬Ý
GBKEE µoªí©ó 2013-3-26 17:02





    ¥ô¦ó°ª²`¨ç¼Æ³£¨S¥Î¨ì... XDD

            Dim K1, K2, K3 As Integer
            Dim yy, dd, mm, wek, dss, dds31, dds30, dds2, dds28, dds29 As Integer
            Dim uny, unm, und, unym, unmd As String
            Dim weeks(6) As String

            DTP1 = DaTiPi.Text
            uny = InStr(DTP1, "¦~") - 1 : unm = InStr(1, DTP1, "¤ë") : und = InStr(DTP1, "¤é") - 1
            unym = Mid(DTP1, uny + 1, unm - 5) : unmd = Mid(DTP1, unm + 1, und - 1)

            K1 = InStr(1, DTP1, "¦~") : K2 = InStr(1, DTP1, "¤ë") : K3 = InStr(1, DTP1, "¤é")

            yy = Mid(DTP1, 1, K1 - 1) '¦~
            mm = Mid(DTP1, K1 + 1, (K2 - K1) - 1) '¤ë
            dd = Mid(DTP1, K2 + 1, (K3 - K2) - 1) '¤é
            dss = 30 + ((mm + (mm > 7)) Mod 2) + (2 + (yy Mod 4 = 0) + (yy Mod 100 = 0) * (yy Mod 400 <> 0)) * (mm = 2) '¤é ¤G¤ë±M¥Î
            dds31 = 31 : dds30 = 30  'dds ¬°  31¤é ©M 30¤é
            dds2 = dss '¤é ¤G¤ë±M¥Î

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2013-3-27 09:46 ½s¿è

¦^´_ 19# mark15jill

¸U¦~¾ä¦b²{¦bªº¨t²Î¤º¤w¸g¬O¤º«Ø¤F
¤£¥ÎVBA¤é´Á¨ç¼Æ­pºâ¬P´Á´X¡Aª½±µ¥Î°ò·Ç¤é´Á¶¡¶Z¨Óºâ´N¹ï¤F
¨t²Î¤ä´©³Ì¤p¤é´Á1900/1/1¬O¬P´Á¤é¨ä¤é´Á§Ç¦C¸¹¬°1
  1. d = CDate(InputBox("¿é¤J§¹¾ã¦è¤¸¤é´Á¦r¦ê", , Date))
  2. MsgBox IIf((d - 1) Mod 7, (d - 1) Mod 7, 7)
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : §ïÅܦۤv¬O¦Û±Ï¡A¼vÅT§O¤H¬O±Ï¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD