- ©«¤l
- 549
- ¥DÃD
- 152
- ºëµØ
- 0
- ¿n¤À
- 691
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN7
- ³nÅ骩¥»
- OFFICE 2010
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-8-10
- ³Ì«áµn¿ý
- 2022-9-7
|
¥»©«³Ì«á¥Ñ PKKO ©ó 2015-1-20 22:33 ½s¿è
¦^´_ 5# diolin
·PÁÂ,¤S¦¬Ã¬¤F!
PO¤W½d¨Ò»¡©ú
Collection ª«¥ó½d¨Ò
¥»½d¨Ò«Ø¥ß¤@Ó©R¦W¬° MyClasses ªº Collection¡A¨Ã¥B¦A«Ø¥ß¤@Ó¹ï¸Ü¤è¶ô¡AÅý¨Ï¥ÎªÌ¥i±q¹ï¸Ü¤è¶ô¤¤±Nª«¥ó·s¼W¨ì¸Ó¶°¦Xª«¥ó¤¤¡CYnÆ[¹îµ{¦¡¦p¦ó¹B§@¡A½Ð¥ý¦b¡u´¡¤J¡v¥\¯àªí¤W¿ï¨ú¡uª«¥óÃþ§O¼Ò²Õ¡v«ü¥O¡AµM«á¦b Class1 ªº¼Ò²Õ¼h¦¸¤¤«Å§i¤@Ó¤½¥ÎÅܼơA©R¦W¬° InstanceName (Public InstanceName)¡A¦¹ÅܼƥΨÓÀx¦s¨CÓª«¥óÃþ§O°õ¦æÓÅ骺¦WºÙ¡C¤£n§ó§ïª«¥óÃþ§Oªº¹w³]¦WºÙ Class1¡C±N¤U¦Cµ{¦¡½X½Æ»s¨ì¥t¤@Ó¼Ò²Õªº¡u¤@¯ë¡v°Ï¬q¤¤¡AµM«á¦b¥t¤@Óµ{§Ç¤¤¥H ClassNamer ³¯z¦¡¨Ó±Ò°Ê¤§¡C(¥»½d¨Ò¥u¾A¥Î©ó¦³¤ä´©ª«¥óÃþ§Oªº¥Dµ{¦¡¡C)- Sub ClassNamer()
- Dim MyClasses As New Collection ' «Ø¥ß¤@Ó¶°¦Xª«¥ó (Collection)¡C
- Dim Num ' °O¼Æ¥ÎÅܼơA¥Î¨Ó°O¼Æª«¥óӼơC
- Dim Msg As String ' ´£¥Ü°T®§¥ÎÅܼơC
- Dim TheName, MyObject, NameList ' ª«¥ó¸ê°T¥ÎÅܼơC
- Do
- Dim Inst As New Class1 ' «Ø¥ß Class1 ªº·s°õ¦æÓÅé¡C
- Num = Num + 1 ' §â°O¼ÆÅÜ¼Æ Num ¥[¤@¡AµM«án¨D¨Ï¥ÎªÌ¿é¤J·sª«¥óÓÅ骺¦WºÙ¡C
- Msg = "Please enter a name for this object." & Chr(13) _
- & "Press Cancel to see names in collection."
- TheName = InputBox(Msg, "Name the Collection Items")
- Inst.InstanceName = TheName ' ±N¦WºÙ«ü©wµ¹·sª«¥óÓÅé¡C
- ' ±N¨Ï¥ÎªÌ¿é¤Jªº¦WºÙ¥[¨ì¶°¦Xª«¥ó¤¤¡C
- If Inst.InstanceName <> "" Then
- ' ±N·s¦WºÙ¥[¨ì¶°¦Xª«¥ó¤¤¡C
- MyClasses.Add item := Inst, key := CStr(Num)
- End If
- ' ±N²{¦bª«¥óªº¤Þ¥ÎÄÀ©ñ±¼¡A¥H¹ï¤U¤@Óª«¥ó°µ°Ê§@¡C
- Set Inst = Nothing
- Loop Until TheName = ""
- For Each MyObject In MyClasses ' «Ø¥ßª«¥ó¦WºÙ²M³æ¡C
- NameList = NameList & MyObject.InstanceName & Chr(13)
- Next MyObject
- ' ±N¦WºÙ²M³æ¥H°T®§¤è¶ôÅã¥Ü¥X¨Ó¡C
- MsgBox NameList, , "Instance Names In MyClasses Collection"
- For Num = 1 To MyClasses.Count ' ±N¦Uª«¥ó±q¶°¦Xª«¥ó¤¤²¾°£¡C
- MyClasses.Remove 1 ' ¦]¬°¨C²¾°£¤@Óª«¥ó«á¡A¶°¦Xª«¥ó
- ' ¥»¨·|¦Û°Ê«±Æª«¥ó¶¶§Ç¡A¬G°j°é¤¤¥u»Ýn²¾°£²Ä¤@Ó
- Next ' ª«¥ó§Y¥i¡C
- End Sub
½Æ»s¥N½X |
|