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

[µo°Ý] ¦p¦ó¥[¸ê®Æ

¥»©«³Ì«á¥Ñ Hsieh ©ó 2011-1-7 20:27 ½s¿è

¦^´_ 20# FAlonso
­º¥ý§Ú¥²¶·¥ý¨ØªAªº¨Dª¾ºA«×
°O±o·íªì­è±µÄ²°}¦C»Pdictionaryª«¥ó®É¡A¤]¦³µÛ¸ò§A¬Û¦PªººÃ´b
¦ý§Ú´N¬O¤£¨D¬Æ¸Ñªº­Ó©Ê¡A´N§âTRANSPOSE¨ç¼Æ§@¬°³B²z°}¦C°ÝÃDªº¤èªk¦Ó¤w
¤µ¤Ñ¹J¨ì±z´£¥XºÃ°Ý¡A¨º´NÅý§Ú­Ì¤@°_¨Ó±´°Q¥Lªº¶ø¯µ§a!
¥H¤U¬O§Ú­Ó¤H¹ï°}¦C»Pdictionaryªº²z¸Ñ¤è¦¡
´£¨Ñ±z°µ°Ñ¦Ò
­Y¦³¤£¬O¤§³B¡AÁٽЦU¦ì«e½ú«ü¥¿

1.Range("A1:A4")ºâ¤£ºâ¬O¤@­Ó°}¦C?
¬O°}¦C¡A¦Ó¥B¬O¤Gºû°}¦C
¥H¤U¦Cµ{¦¡½X´ú¸Õ¸Ó°}¦Cª¬ºA
  1. Sub Ex()
  2. Dim j%, i%, Ar As Variant
  3. On Error Resume Next
  4. Ar = [A1:A4]
  5. Do Until j > 2  'j¬°­pºâÂà¸m¦¸¼ÆªºÅܼÆ
  6. MsgBox IIf(IsArray(Ar), "ar¬O°}¦C", "ar¤£¬O°}¦C") '¬O§_¬°°}¦C
  7. i = 1
  8. Do Until Err.Number > 0
  9. i = i + 1
  10. k = UBound(Ar, i)
  11. Loop
  12. MsgBox "¦¹°}¦C¬°" & i - 1 & "ºû°}¦C" & Chr(10) & "³QÂà¸m" & j & "¦¸" '²Ä¤@ºû¤W­­(¦C¼Æ)
  13. Err.Clear
  14. Ar = Application.Transpose(Ar)
  15. j = j + 1
  16. Loop
  17. End Sub
½Æ»s¥N½X
2.¬°¤°»ò¥´ª½ªº®æ¤l,¤@¦¸transpose´N¥i¥H,¥´¾îªº­n¨â¦¸?
¨º¬O¦]¬°joinªº¤Þ¼Æ¥²¶·¬O¤@ºû°}¦C

3.d(mystr) = d(mystr) + A.Offset(, 4).Value³o¥y¬O«ç¸ÑÄÀ,¬°¤°»ò¥i¥H§@²Ö¥[ªº§@¥Î?
¦]¬°dictionaryª«¥ó¡A§A¥i¥Hª½±µµø¬°°}¦C¡A·í¤¤ªºmystr´N¬O¯Á¤Þ­È(¤@¯ë°}¦C·|¬O¼Æ­È,¦b¦¹¬O°£¤F°}¦C«¬ºA¥H¥~ªº¥ô¦ó¸ê®Æ«¬ºA)¡A¥Nªí¦¹ª«¨£¬Y­Ó¤¸¯Àªº«ü©w¯Á¤Þ
d(mystr)´N¬Od³o­Óª«¥óªºmystr¦ì¸mªº¨º­Ó¤¸¯À
d(mystr) = d(mystr) + A.Offset(, 4).Value  
ÅܼÆ(·s­È)=ÅܼÆ(­ì­È)+±`¼Æ
´N¦n¤ñ¤@­ÓÅܼƤF¡A©Ò¥H¦ÛµM´N¯à­pºâ²Ö¥[­È
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

²Ä¤G­Ó°ÝÃD¥ýÀÁ¤U¤£ªí
²Ä¤T­Ó°ÝÃD¬O§_«ü¥ý§âmystrª`¥U¦bdictionaryªºindex,d(mystr),¦Ó¸Óindexªºdefault¸ê®Æ¬° = 0(§Y d(mystr)=0), ¦A¤Þ¥Hoffset(,4)­p¼Æ?ÁÙ¦³dictionary·Ó²z»¡À³¸Ó¬O´XD array?

·Pı·U¨Ó·Uªñ¯u¬Û!
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

Dictionaryª«¥ó·í¥[¤JKEYªº¦P®É§Y²£¥Í¹ïÀ³¸ÓKEYªº­È¬°Emptyªºªì©l­È
¾ã­Óª«¥ó·í¥iµø¬°¤Gºû°}¦C
¨ä²Ä¤@ºû«h¬O¸Óª«¥óªº¼Æ¶q
¨ä²Ä¤Gºû«h¬O¸Óª«¥óªºkeys»Pitems
¸Ó°}¦C¤j¤pªí¥Ü¦p¤U:
ThisArray(d.count,2)
¦ý§AµLªk¥HINDEX«ü©w¸Ó°}¦C
¦]¬°³o¥u¬O±N¨äµø¬°¤Gºû°}¦C
¦ý¹ê»Ú¤W¥L¬O2­ÓÁa¦Cªº°}¦C¦X°_¨Ó
©Ò¥H¤@¯ëÀ³¥Î¤W·|¥H¨äKeyª½±µ«ü©w¨ì¹ïÀ³ªºItem
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

·PÁ¦U¦ì¥ý¶i
¤§«e°w¹ïdictionary & transpose Á`¬O¤£¤Ó¤F¸Ñ
¬Ý§¹¥»¤å³¹«á¡AÁ`ºâ¤ñ¸û¤F¸Ñ¨ä¥Îªk¤F¡C
100 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¥»©«³Ì«á¥Ñ linshin1999 ©ó 2011-1-8 11:26 ½s¿è

¦^´_ 16# basarasy

Åܼƭn¥ÎObject¶Ü?
Dim d as Object ??



Dim d                                                              '«Ø¥ß¤@­ÓÅܼÆ
Set d = CreateObject(Scripting.Dictionary)


VBA ¤¤Åܼƪº«Å§i¤£©ú½T»¡©ú«¬§O¬°¦ó®É,¥¦ªº«¬§O´N¬O Variant ¥¦ªº·N«ä´N¬O¤°»ò«¬ºA³£¥i¥H,
1)¦³¦n³B:´N Scripting.Dictionary ¨ÓÁ¿,¥¦­n³BÍù¸òµÛ¨Óªº °}¦C ©Ò¥H¥¦ªº«¬§O·|¸òµÛ«á­±ªº °}¦C ¶],¥¦ªº«¬§O´N¤@©w­n¬O Variant ,¦pªG没¦³ variant ³o­Ó«¬§O, Dictionary ´N¤£¦s¦b¤F .
2)¦³¯ÊÂI:´N¬O¤£©ú½T,¹ï©ó²ßºD©ú½T«¬§Oªº¤H·|«Ü¤£²ßºD,§Ú¤]¬O³o¼Ë.

¤µ¤Ñ¦A¦^ÀYŪ Hsieh ª©¥D ©M TAlonso ºë±mªº½×­z,¤~ª`·N¨ì¦³³o«h¦^´_,¯u¤£¦n·N«ä.


¦^´_ 24# b9208

¤Óºë±m¤F,§Ú¤]¨Ó¥[½X.
V98

TOP

¦^´_ 25# linshin1999
dim d as object
³o¬O¥¿½T«Å§i¡Adictionary¥L¬O­Óª«¥ó©Ò¥H«Å§i¬°ª«¥ó¨S¿ù
dictionary³o­Óª«¥ó¤£·|¦]¬°¥Lªºkey»Pitem²£¥Í¸ê®Æ«¬ºAÅܤÆ
§A¥i±N¦¹ª«¥ó¬Ý¦¨¤@­Ó®e¾¹¡A¦¹®e¾¹ªº¤º®eª«¨Ã¤£·|§ïÅܦ¹®e¾¹¥»¨­ªº©Ê½è

©Ò¥HVBA»¡©ú¤¤´£¨ì
dictionaryª«¥ó¡A¨äkey¦¡°£¤F°}¦C¥H¥~ªº¥ô¦ó¸ê®Æ«¬ºA¡A¦Óitem«h¥i¬°¥ô¦ó§ÎºAªº¸ê®Æ¡C
¤@­ÓÃöÁä¦r¥i¹ïÀ³¥ô¦óªº¸ê®Æ¡A³o¬O¦¹ª«¥óªº¯S©Ê¡C
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 26# Hsieh
¦hÁÂH¤j«üÂI,²{¦b²×©ó§¹¥þ¸Ñ³q¤F
¥t¥~¦b#18,§Ú·s¼W¤F¤@¨Çµ§°O,§Æ±æ¥H«á¹ï¥L¤H¦³¥Î
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

«ç»òÁ¿©O?´N¬O¤@ÂIÂI¥[¤@ÂIÂI¥[,µM«á´NÀ´¤F,ÁÂÁ¦U¦ì,©ñ°²¤F¤j®a³£ÁÙ¦b§V¤O,FAlonso¥xÆW¦n§N,¨º¸ÌÁÙ¦n§a!
V98

TOP

linshin1999 ¥S

©ó#18¹ïtranspos»¡©ú«D±`¸Ô²Ó
«Øij¹ïtransposÅܤƤ£¤F¸Ñªº¡A¥i¥H«e©¹«ôŪ¡C
«D±`·PÁÂ
100 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦^´_ 29# b9208


    §Ú¬O«á¾Ç, ½×¾Â¤W½Íªº³£¬O§Ú¶i¨BªºÂ³­¹,·|«Ü¬Ã±¤ªº,³o­Ó½×¾Â¯uªºÀ°§U§Ú«Ü¦h,­É¦¹¦A»¡ÁnÁÂÁ¤j®a!!:D
V98

TOP

        ÀR«ä¦Û¦b : ¯à¥I¥X·R¤ß´N¬OºÖ¡A¯à®ø°£·Ð´o´N¬O¼z¡C
ªð¦^¦Cªí ¤W¤@¥DÃD