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

ªí³æ±±¨î¶µµLªk¦Û°Ê§R°£

ªí³æ±±¨î¶µµLªk¦Û°Ê§R°£

­º¥ý·PÁÂGBKEE¤j¤j¤§«eªº«ü¾É¡A
Àɮ׬°§ó§ïGBKEE¤j¤jµ{¦¡½X©Ò²£¥Íªº¡A¤£¹L¹J¨ì¤@­Ó¤p°ÝÃD¡A
´N¬Oµ{¦¡¤@ª½µLªk¦Û°Ê§R°£±±¨î¶µ¡A
¤@ª½¥X²{¤U¹Ï¡G
111.jpg
¤]ª¦¤F«Ü¦h¤å³¹¡A¦ý´N¬O¸Õ¤£¥X¨Ó¡A
  1.     Dim sp As Control
  2.     For Each sp In UserForm1.Frame2.Controls
  3.        If sp.Name Like "ToggleButton*" Then sp.Delete
  4.     Next
½Æ»s¥N½X
¿ù»~¤@ª½¥X²{¦b sp.Delete ³o¸Ì¡A¹ê¦b§ä¤£¨ì¤èªk¤F¡A
¦]¦¹¡A½Ð¦U¦ì¤j¤jÀ°¦£«ü¾É¤@¤U¡A·PÁ¡I

test.zip (10.43 KB)

§Ú¬O´µ¦h

¦^´_ 1# reangame
  1. If sp.Name Like "ToggleButton*" Then Controls.Remove (sp.Name)
½Æ»s¥N½X
¥i°Ñ¦Ò³o¸Ì
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 2# GBKEE

GBKEE¤j¤j¡A±z¦n¡G
µ{¦¡½X§ï¦¨¡GIf sp.Name Like "ToggleButton*" Then Controls.Remove (sp.Name)¡A½T¹ê¥i°õ¦æ§R°£¡A
¦A½Ð±Ð¤@­Ó°ÝÃD¡A­n¦p¦óÅý¦Û°Ê²£¥ÍToggleButton«ö¶sÂIÀ»®É¡AÅý«ö¤U¥hªºToggleButton«ö¶s¦rÅéÅܦ¨²ÊÅé¦r©Î¬O§ïÅÜ­I´ºÃC¦â?
¸ò³o­Ó¬ÛÃöªºÆ[©ÀÀ³¸Ó¬O±±¥ó¦Û°Ê¥[¤Jµ{¦¡½X¡A§Ú¸Õ¹L¤U­±ªº¤èªk
  1.     da = Val(Day(day2))
  2.     For i = 1 To da
  3.         With UserForm1.Frame2.CodeModule
  4.             X = .CountOfLines
  5.             .InsertLines X + 1, "Private Sub ToggleButton" & i & "_Click()"
  6.             .InsertLines X + 2, "  msgbox ToggleButton & i "
  7.             .InsertLines X + 3, "End Sub"
  8.         End With
  9.     Next i
½Æ»s¥N½X
¥i¬O«o¨S¿ìªk°õ¦æ¡A³o­ÓÆ[©À¤@ª½·d¤£À´¡AÁٽФj¤j«ü¾É¤@¤U¡A·P®¦~
§Ú¬O´µ¦h

TOP

¦^´_ 3# reangame
  1. Dim XToggle() As New Class1
  2. Private Sub ComboBox1_Change()
  3. If ComboBox1 <> "" And ComboBox2 <> "" Then ¦æ¨Æ¾ä»s§@
  4. End Sub
  5. Private Sub ComboBox2_Change()
  6. If ComboBox1 <> "" And ComboBox2 <> "" Then ¦æ¨Æ¾ä»s§@
  7. End Sub
  8. Sub ¦æ¨Æ¾ä»s§@()
  9.     Dim sp As Control
  10.     For Each sp In UserForm1.Frame2.Controls
  11.        If sp.Name Like "ToggleButton*" Then Me.Controls.Remove sp.Name
  12.     Next
  13.     day1 = DateSerial(Val(ComboBox1), Val(ComboBox2), 1)
  14.     day2 = DateSerial(Val(ComboBox1), Val(ComboBox2) + 1, 0)
  15.     w = Weekday(day1, vbMonday)
  16.     ReDim XToggle(day1 To day2)
  17.     For I = day1 To day2
  18.         k = Int((Day(I) + w - 2) / 7)
  19.         s = Weekday(I, vbMonday)
  20.         kk = Int((Day(I) + w - 2) / 7)
  21.         If kk = 5 Then
  22.             Frame1.Height = 262
  23.         Else
  24.             Frame1.Height = 222
  25.         End If
  26.         
  27.          With Frame2.Controls.Add("forms.ToggleButton.1")
  28.             .Top = (k * 38) - 1
  29.             .Left = (42 * (s - 1)) - 2
  30.             .Height = 38
  31.             .Width = 42
  32.             .Caption = Day(I)
  33.             Set XToggle(I).Toggle = Controls(.Name)
  34.             'ª«¥óÅܼƫü©w¬° Controls(.Name)
  35.         End With
  36.     Next
  37. End Sub
½Æ»s¥N½X
  1. Option Explicit
  2. Public WithEvents Toggle As MSForms.ToggleButton
  3. Private Sub Toggle_Click()
  4.     With Toggle
  5.         .BackStyle = 1
  6.         If .Value Then
  7.             .Font.Size = 18
  8.             .Font.Bold = True
  9.             .BackColor = vbYellow
  10.         Else
  11.             .Font.Size = 12
  12.             .Font.Bold = False
  13.             .BackColor = &H8000000F
  14.         End If
  15.     End With
  16. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# GBKEE
GBKEE¤j¤j¡A±z¦n¡G
±z©Ò»s§@ªºµ{¦¡½X½T¹ê¥i¥H°õ¦æ¡A¤£ª¾¤p§Ì¥H¤Uµù¸Ñ¬O§_¥¿½T¡G
Dim XToggle() As New Class1    ->©w¸qXToggle()¬°ª«¥óÃþ§O¼Ò²Õ¡A¨Ï¥Î®É¾÷??
ReDim XToggle(day1 To day2)  ->­«·s©w¸qXToggle°}¦C¡A¼Æ¶q¬°day1 To day2¡A¦ý¬°¤°»ò»Ý­n©w¸q³o­Ó°}¦C? ¦AªÌ°}¦C¤£¬O±q0¶}©l¡AXToggle(i)«ç»ò¤£·|¥X¿ù?
Set XToggle(I).Toggle = Controls(.Name)     ->³]©wXToggle(I)±±¨î¶µªº¦WºÙ¡H  .Toggle¬O¤°»ò¥\¥Î¡H(¥HMsgBox XToggle(i).ToggleÀ˵ø§¡¬°false¡AF1¤]¬d¤£¨ì)
Public WithEvents Toggle As MSForms.ToggleButton    ->¤½§iToggle¬Oªí³æ¤¤ªºToggleButton«ö¶s
¦p¦ó¤À¿ëShapes¡BOLEObjects¡BControlsªº®t§O©Î¨Ï¥Î®É¾÷??
°Ñ¬ã«áªº·P·Q....
¥u¯à»¡VBµ{¦¡½Xªº¥@¬É¯u¹³¦t©z¯ë¯EÃvµL«­¡A
³o¨Çµ{¦¡½X¤£ª¾¹D±z¬O¦p¦óºc«ä¥X¨Óªº¡A¦p¦ó¤~¯à¦³³o¼Ë¼¶¼gªº·Qªk¤Î¯à¤O...
¯uªº«Ü·Q¦¨¬°¹³±z¤@¼Ëªº°ª¤â¡AµM«á¦AÀ°§U§O¤H¦¨ªø¡A
Á`¤§¡A¯uªº«Ü¨ØªA±z¡I
§Ú¬O´µ¦h

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-6-15 19:11 ½s¿è

¦^´_ 5# reangame
Dim XToggle() As New Class1    ->©w¸qXToggle()¬°ª«¥óÃþ§O¼Ò²Õ¡A¨Ï¥Î®É¾÷??
·í§A¦³³\¦h¬Û¦Pª«¥óªº¹w³]¨Æ¥ó,¤£»Ý¨C£¸ª«¥ó¼g¤@¨Æ¥óµ{¦¡½X.

¦AªÌ°}¦C¤£¬O±q0¶}©l¡AXToggle(i)«ç»ò¤£·|¥X¿ù?
  1. Option Explicit
  2. Sub Ex()
  3.     Dim ar(-5 To 5)
  4.     ar(-5) = "Why"
  5.     MsgBox ar(-5)
  6. End Sub
½Æ»s¥N½X
¦bªí³æ¤¤ ªº Dim XToggle() As New Class1 -> «Å§i XToggle() «¬ºA¬° ·sªº Class1
4# ªºª«¥ó¼Ò²Õ¦WºÙ¬° Class1¬°¹w³]ªº.·s¼W¨Ì§Ç·|¬° Class2,Class3....,¥ç¥i¨Ì³ß¦n©R¦W,
Dim XToggle() As New GbKee


Set XToggle(I).Toggle = Controls(.Name)     ->³]©wXToggle(I)±±¨î¶µªº¦WºÙ¡H  
.Toggle¬O¤°»ò¥\¥Î¡H->Public WithEvents Toggle As MSForms.ToggleButton   ¬O³o±±¨î¶µ   

F1¤]¬d¤£¨ì
vbaµøµ¡¤¤¿é¤JToggleButton ¥i¬d¨ì

¦p¦ó¤À¿ëShapes¡BOLEObjects¡BControlsªº®t§O©Î¨Ï¥Î®É¾÷??
vbaµøµ¡¤¤¿é¤JShapes ....¥i¤F¸Ñ
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 6# GBKEE

¤S¤W¤F¤@½Ò¡A·PÁÂGBKEE¤j¤j¡I
§Ú¬O´µ¦h

TOP

        ÀR«ä¦Û¦b : ¤Hªº¤ß¦a¬O¤@²¥¥Ð¡A¤g¦a¨S¦³¼½¤U¦nºØ¤l¡A¤]ªø¤£¥X¦nªºªG¹ê¡C -
ªð¦^¦Cªí ¤W¤@¥DÃD