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

[µo°Ý] ¦p¦ó§Q¥Î°j°éª½±µ§ïLabel ªºname?(¤w¸Ñ¨M)

¥»©«³Ì«á¥Ñ icestormer ©ó 2012-5-6 09:33 ½s¿è

¦^´_ 9# Hsieh


    ­è¤~ªºµ{¦¡§¹¥þ¥i¥H¨Ï¥Î¦ý§Ú¦³¤G­Ó°ÝÃD ÁÙ¬O¤£À´ ·Q½Ð°Ý¶Wª©


§Ú¦pªG§âµ{¦¡§ï¦¨³o¼Ë

Private Sub UserForm_Initialize()
'·s¼W2Äæ8¦C
For j = 1 To 2
k = 0
    For i = 1 To 10
    k = k + 1
      With Controls.Add("Forms.Label.1", , True)'¤£§ï¥¦NAME Åý¥¦¥ÑLabel1 -21
      .Caption = .Name
         .Top = 20 * (i - 1) + 5
         .Left = 160 * (j - 1) + 5
         .Width = 155
         .Height = 18
         ComboBox1.AddItem .Name
      End With
    Next
Next
End Sub

µM«á§Ú¥t¥~§Ë¤@­ÓCMD ¤º®e¬O

Label1.caption ="´ú¸Õ" <<·|¥¢±Ñ§ä¤£¨ìª«¥ó
----------------------------------------------------------------------------------------------------------------------------
¦ý¦pªG§Ú¬O¥ý¨Æ¦bªí³æ¤W ¥ý©Ô¥X¤@­ÓLAbel1«á

³o®É¥Ñ¤WÀYµ{¦¡½X²£¥ÍªºLabel 1-21 >Åܦ¨>Label2-21
§Ú¦A«öCMD ªº¥¨¶° Óý¬O¥i¥H§ïÅÜLable1.caption

³o¬O¬°¤°»ò©O? µ{¦¡¥Í¦¨ªºLabel1 ¬°¦ó¨Sªk§Q¥Î Label1.caption ="´ú¸Õ" ¨Ó§ïÅÜ¥¦©O?¦ý¨Æ¥ý©Ô¦bªí³æ¤WªºLabel1.caption Óý¥i¥H?¹ê¦b¤£À´©O
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
²Ä¤G°ÝÃD¬O.

¹³µ{¦¡½X¥Í¦¨ ¥X Label1 -21 ³o³¡¥÷¥i¥H§Q¥Î°j°é §â¥¦­Ì¤@¦¸³£³]©w¦¨visible=false? ¬O­n§Q¥Îtabindex ¶Ü? ÁÙ¬O­n¦p¦ó¼g©O?

TOP

¦^´_ 11# icestormer
ªí³æ¹ê»Ú¤W¤w¦s¦bªº±±¨î¶µ ¤~¥i¥Î  Label1.Caption = "´ú¸Õ"  
With Controls.Add("Forms.Label.1", , True)  ©Ò·s¼Wªº±±¨î¶µ ¤£¬O ªí³æ¹ê»Ú¤W¤w¦s¦bªº±±¨î¶µ
  1. Sub Ex()
  2.     Dim I As Integer
  3.     Controls("Label1").Caption = "´ú¸Õ"
  4.     For I = 1 To 21
  5.         Controls("Label" & I).Visible = False
  6.     Next
  7.    
  8. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ icestormer ©ó 2012-5-6 22:28 ½s¿è

¦^´_ 12# GBKEE


    ·PÁ§A ¸g­è¤~¸Õ¤F±zªºµ{¦¡½X §¹¥þ¥i¥H¥Î¤F

¤£¹L·Q°Ý¥t¤@­Ó°ÝÃD ¦pªG ¤£¥Îfor next¥i¥H§ï¥Îfor each  X  in Label ¤§Ãþªº??
´N¬O¦pªG¦Û­qªí³æ¤W ¦³
TextBox 5­Ó
Label  10­Ó
commandbutton 6­Ó

§Ú¥i¥H§Q¥Îfor each °w¹ï Label  ²Î­p¤@¦@¦³¦h¤Ö­ÓLabel ?

sub commandbutton_click() <<¥Ø«e¥u·|³o­Ó¦Ó¤w,¦ý¥L¥u·|­pºâ¥þ³¡ªº±±¨î¶µ¦³¦h¤Ö©O.
for each  x in controls

     i=i+1
next
msgobx  "¤@¦@¦³¦h¤Ö:" & i & "±±¨î¶µ"

end sub
================================================================
·Q¦A°Ý±z¤@­Ó°ÝÃD¦pªG§Ú·Q§Q¥ÎÂù°j°é¼g¥X ¦p¤Uªº±Æ§Ç ­n«ç¼g©O?«ç·Q³£·Q¤£¥X¨Ó..

1        2        3        4        5        6        7
8        9        10        11        12        13        14
15        16        17        18        19        20        21

TOP

¦^´_ 13# icestormer

­pºâª«¥ó¼Æ¶q¡A¥HTypeName¨Ó§PÂ_¬O­þ¤@ºØ±±¨î¶µ
  1. Private Sub CommandButton3_Click()
  2. Dim Ct As Control
  3. For Each Ct In Controls
  4.   If TypeName(Ct) = "Label" Then cnt = cnt + 1
  5. Next
  6. MsgBox cnt
  7. End Sub
½Æ»s¥N½X
­nÅã¥Ü3¦C7Äæ¸ê®Æ¡A¤@Äæ¦C¼Æ°µ°j°é
  1. Sub ex()
  2. Dim ar(1 To 3, 1 To 7)
  3. For i = 1 To 3 '3¦C
  4.   For j = 1 To 7 '7Äæ
  5.      k = k + 1 '­È
  6.      ar(i, j) = k '±N­È¼g¤J°}¦C
  7.   Next
  8. Next
  9. For i = 1 To 3 '´`¦C°j°é
  10.    m = Join(Application.Index(ar, i), ",") '¨ú¥X¤@¦C
  11.    mystr = IIf(mystr = "", m, mystr & Chr(10) & m) '¦êÁp¦r¦ê
  12. Next
  13. MsgBox mystr 'Åã¥Ü¦r¦ê
  14. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 14# Hsieh


       ·PÁ ¤G¦ì¶Wª©^^ ¨Ó¥h¸Õ¬Ý¬Ý
§Ö¥i¥H¦³Åv­­¤U¸ü¤F. ¨ì®É¥h¤U¸üª©¤W¥ý¶i¤À¨ÉªºVBA¾Ç²ßÀÉ®× ¦n¦n¾Ç²ß

TOP

        ÀR«ä¦Û¦b : ¥Í®ð¡A´N¬O®³§O¤Hªº¹L¿ù¨ÓÃg»@¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD