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

[µo°Ý] ¨ÌÄæ¼Æ«Ø¥ß¿ï¶µ¡A¨Ã¦³¬Û¦üµ{¦¡«ü¥O

[µo°Ý] ¨ÌÄæ¼Æ«Ø¥ß¿ï¶µ¡A¨Ã¦³¬Û¦üµ{¦¡«ü¥O

§Ú·Q¨Ì·Ó¤u§@ªíªºÄæ¼Æ
«Ø¥ß¦P¼Ë¼Æ¶qªº¿ï¶µ«ö¯Ã

¨C­Ó¿ï¶µ¿ï¨ú«á
³£¯àÅã¥Ü¸Ó¿ï¶µªº¤º®e

¥Ø«e¥H¬d¨ìªº §Ú¥u·|¼g¼W¥[¿ï¶µ
¨C­Ó¿ï¶µªºµ{¦¡½X¤£ª¾«ç»ò¼g

ÁٽЦU¦ì°ª¤â«ü¾É
ÁÂÁÂ
  1. Private Sub UserForm_Initialize()
  2.     i = Cells(1, 1).End(xlToRight).Column
  3.     h = 0
  4.     Dim myC As Control
  5.    
  6.     For a = 1 To i
  7.         Set myC = Controls.Add(bstrprogid:="Forms.optionButton.1")
  8.         myC.Top = h
  9.         h = h + 20
  10.         myC.Caption = Cells(1, a)
  11.     Next a
  12. End Sub

  13. '¨C­Ó«ö¶s³£¬OÃþ¦ü³o¼Ëªº¥\¯à
  14. Private Sub OptionButton1_Change()
  15.     Label1.Caption = OptionButton1.Caption
  16. End Sub
½Æ»s¥N½X

¥»©«³Ì«á¥Ñ lpk187 ©ó 2015-6-16 22:23 ½s¿è

¦^´_ 1# lyc43210


   
¤]¤£ª¾¹ï¤£¹ï¡A¨þ¨þ¡I§Ú¤]¬O½m²ß
UserForm:
  1. Dim X_OB() As New Class1

  2. Private Sub UserForm_Initialize()
  3.     I = Cells(1, 1).End(xlToRight).Column
  4.     h = 0
  5.     ReDim X_OB(1 To I)
  6.     Dim myC As Control
  7.     For A = 1 To I
  8.         Set myC = Controls.Add(bstrprogid:="Forms.optionButton.1")
  9.         myC.Top = h
  10.         h = h + 20
  11.         myC.Caption = Cells(1, A)
  12.         Set X_OB(A).OB = Controls(A)
  13.     Next A
  14. End Sub
½Æ»s¥N½X
Class1:
  1. Public WithEvents OB As MSForms.OptionButton

  2. Private Sub OB_Click()
  3.     UserForm1.Label1 = OB.Caption
  4. End Sub
½Æ»s¥N½X

TOP

¤µ¤Ñ·Q¨ì 1­Ó¤èªk ¤£»Ý¥Î  Dim X_OB( ) As New Class1  ( ¦h¤@­Ó Class )
¦Ó¬O§â private  WithEvents OB_±±¥ó°}¦C  As MSForms.OptionButton ª½±µ©ñ¦b UserForm  ¸Ì­±
´N¥i¥H¹ê²{±±¥ó°}¦Cªº¤èªk
¥i¥H´î¤Ö³Â·Ð
¦³µy¬° try ¹L, ¦n¹³¥i¦æ  ......  good!!

TOP

¦^´_ 2# lpk187

ÁÂÁÂ

³æ¯Â³o¼Ë¨Ï¥Î¥i¥H
¥i¬O­Y­n®M¥Î¶i¨ä¥Lµ{¦¡
¦³®É·|²{¦b¥i¥H µy·L±±¨î¹³°µ¨Ç­×§ï«á ´N¤S¤£¦æ¤F
±`±`·|¦b  Set X_OB(A).OB = Controls(A)     ³o¦æ¥X²{¿ù»~

§Æ±æ°ª¤â­Ì¯àÄ~Äò«ü¾É
ÁÂÁÂ

TOP

¦^´_ 3# bobomi
ÁÙ¬O·s¤â ¬Ý¤£À´·N«ä
¥i¥H³Â·Ð«e½ú ¦h¸ÑÄÀ¤@ÂI¶Ü
·PÁÂ

TOP

¦^´_ 4# lyc43210


   §A¨S¦³§iª¾°µ¤F¤°»ò¼Ëªº­×§ï«á²£¥Í°ÝÃD¡C
©Ò¥H«ÜÃø¥h°µ¥X¦^µª¡I
¥i¥Hªº¸Ü¡C§â­×§ï¦³°ÝÃDªºµ{¦¡½X¥á¤W¨Ó¡A³o¼Ë­n¦^µª§A¤]¤ñ¸û¦³¤è¦V

TOP

¦^´_ 6# lpk187

­è­è¶}­Ó·s¤u§@ªí  ­«·s´ú¸Õ
¤W­±§¹¾ã¤@¼Ò¤@¼Ëªºµ{¦¡½X ª½±µ©ñ¤J
«o³£·|¥X²{¿ù»~
¤£¹L¤§«e³£¬O¥i¥Hªº

Â^¨ú.PNG

TOP

¥»©«³Ì«á¥Ñ lpk187 ©ó 2015-6-17 22:30 ½s¿è

¦^´_ 4# lyc43210


  °²³]§A¬O¦³¨ä¥L±±¨î¶µªº¸Ü
  Set X_OB(A).OB = Controls(A)
³o¸ÌªºÅܼÆA¥i¥H§â¥¦§ï¦¨ Set myC = Controls.Add...·s¼W±±¶µªº¦WºÙ
¦p¤U¡G
Set X_OB(A).OB = Controls(myC.Name)

­ì¥»ªºÅܼÆA¬O«ü¨ì¥¦ªºControls§Ç¸¹¦ì¸m¡A§ï¦WºÙ¬O·|«ü¦V·s¼WControls±±¶µªº¦WºÙ

TOP

¦^´_ 7# lyc43210

TOP

¦^´_ 8# lpk187

¨º¼Ë­×§ï«á¡A¤S¥i¥H¥¿±`°õ¦æ¤F
¦ý¥[¤J§Úªºµ{¦¡«á¤S¤£¦æ¤F
µM«á¤S¥X²{¤£¦Pªº¿ù»~

Â^¨ú.PNG
  1. Private Sub UserForm_Initialize()
  2.     i = Sheets(1).Cells(1, 1).End(xlToRight).Column
  3.     h = 336
  4.    
  5.     If i > 14 Then
  6.         ReDim X_OB(15 To i)
  7.         Dim myC As Control
  8.         For a = 1 To i - 14
  9.             Set myC = Controls.Add(bstrprogid:="Forms.optionButton.1")
  10.             With myC
  11.                 .Caption = "        " & Sheets(1).Cells(1, a + 14).Value
  12.                 .font.Name = "·L³n¥¿¶ÂÅé"
  13.                 .font.Size = 12
  14.                 .font.Bold = True
  15.                 .ForeColor = &HFFFFFF
  16.                 .BackColor = &HFFE66F
  17.                 .Height = 21.75
  18.                 .Width = 144.75
  19.                 .Left = -12
  20.                 h = h + 24
  21.                 .Top = h
  22.                 Sheets(2).ScrollHeight = h + 24
  23.                
  24.             End With
  25.             Set X_OB(a).OB = Controls(myC.Name)
  26.         Next a
  27.     End If
  28. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤ß¤¤±`¦sµ½¸Ñ¡B¥]®e¡B·P«ä¡Bª¾¨¬¡B±¤ºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD