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

[µo°Ý] ª«¥ó±Æ§Ç°ÝÃD"Scripting.Dictionary"

[µo°Ý] ª«¥ó±Æ§Ç°ÝÃD"Scripting.Dictionary"

¥»©«³Ì«á¥Ñ PKKO ©ó 2015-10-6 15:43 ½s¿è

·Q½Ð°Ý¦U¦ì¤j¤j,§ÚSet xd2 = CreateObject("Scripting.Dictionary")
µM«á¤U¤è¶]¦^°é¥i¥H±o¨ì¨â­ÓªF¦è
1:¤£­«½Æªº¦WºÙxd.keys,2:¨C­Ó¦WºÙ¥X²{¹Lªº¦¸¼Æ

°ÝÃD¬O§Ú­n¦p¦ó±o¨ì«e¤T¦W¥X²{¹Lªº¦¸¼Æ¬O´X¦¸?¥H¤Î³o«e¤T¦W¬O½Ö?
  1. '¿é¤J¦¸¼Æ
  2. for °j°é
  3.    xd2(CInt(ar(j))) = xd2(CInt(ar(j))) + 1
  4. next
½Æ»s¥N½X
¤p§Ì¼g±o¥X¨Ó,¦ý¤èªk«Ü·M¬N,·Q½Ð±Ð¦U¦ì¤j¤j¤@©w¦³§ó¦nªº°µªk
¥H¤U¬°¤p§Ìªºµ{¦¡½X(Ãlªø·V¤J!)
§Ú¬O¥ý±NitemsÂର¥t¤@­Ó°}¦C,¦b¥Î°}¦C¶i¦æ±Æ§Ç¤j¤p,µM«á¦A¶]¦^°é¦pªG¦¸¼Æ¬Ûµ¥,´N§â¦WºÙ¨ú¥X,ªÖ©w¦³§ó²©öªº¤èªk,¦]¦¹·Q°Ý°Ý¬Ý¦U¦ì¤j¤jªº¼¶¼g¤èªk!
  1. '§ä¥X³Ì¤jªº¤T­Ó¦¸¼Æ
  2. aar = Split(Join(xd2.items, ","), ",")
  3. ReDim cc(0 To UBound(aar), 1 To 1)
  4. For j = 0 To UBound(aar)
  5.     cc(j, 1) = CInt(aar(j))
  6. Next
  7. a1 = 0: a2 = 0: a3 = 0
  8. For j = 0 To UBound(aar)
  9.       If a1 = 0 Then a1 = Application.WorksheetFunction.Large(cc, j + 1)
  10.       If Application.WorksheetFunction.Large(cc, j + 1) <> a1 And a2 = 0 Then
  11.           a2 = Application.WorksheetFunction.Large(cc, j + 1)
  12.       End If
  13.       If Application.WorksheetFunction.Large(cc, j + 1) <> a1 And Application.WorksheetFunction.Large(cc, j + 1) <> a2 And a3 = 0 Then
  14.           a3 = Application.WorksheetFunction.Large(cc, j + 1)
  15.       End If
  16. Next
  17. str1 = a1 & "¦¸:": str2 = a2 & "¦¸:": str3 = a3 & "¦¸:"
  18. For Each e In xd2.keys
  19.       If xd2(CInt(e)) = a1 Then str1 = str1 & CInt(e) & ","
  20.       If xd2(CInt(e)) = a2 Then str2 = str2 & CInt(e) & ","
  21.       If xd2(CInt(e)) = a3 Then str3 = str3 & CInt(e) & ","
  22. Next
  23. If a1 <> 0 Then str1 = Left(str1, Len(str1) - 1)
  24. If a2 <> 0 Then str2 = Left(str2, Len(str2) - 1)
  25. If a3 <> 0 Then str3 = Left(str3, Len(str3) - 1)
½Æ»s¥N½X
PKKO

·PÁ¨â¦ì¤j¤jªº¦^ÂÐ,³£¬O«Ü¦³·N«äªº«äºû,¤p§Ì·|¦n¦n¬ãŪ¤@¤U!¥ýÁÂÁ¤j¤j­Ì¤F!
PKKO

TOP

        ÀR«ä¦Û¦b : ¶¢¤HµL¼Ö½ì¡A¦£¤HµL¬O«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD