perpah posted a similar question but not found when seraching in this lounge.
...
Dim varEntry As Variant, MIAKEY As String
For Each varEntry In DIC
'Debug.Print varEntry & " " & DIC(varEntry)
MIAKEY = varEntry & " " & DIC(varEntry)
Next varEntry
...
i need to sort this item&key...????
Perphs i need to add in temp array MIAKEY and sort it when the loop for next finished?
sort array from dictionary key
-
- Administrator
- Posts: 78527
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: sort array from dictionary key
See the thread Sort dictionary items.
For a more general sorting procedure, see Collection And Dictionary Procedures on Chip Pearson's website (already mentioned in loop trought dictionary collection).
For a more general sorting procedure, see Collection And Dictionary Procedures on Chip Pearson's website (already mentioned in loop trought dictionary collection).
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: sort array from dictionary key
OK! sorry me for tath, now all work fine...HansV wrote:See the thread Sort dictionary items.
For a more general sorting procedure, see Collection And Dictionary Procedures on Chip Pearson's website (already mentioned in loop trought dictionary collection).
but a dubt. When i declare Dictionary option. Is really required this line:
DIC.CompareMode = vbTextCompare
bsed:
...
If DIC.Exists(CODICE) Then
DIC(CODICE) = DIC(CODICE) + 1
Else
DIC.Add CODICE, 1
End If
...
-
- Administrator
- Posts: 78527
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: sort array from dictionary key
The default value of CompareMode is vbBinaryCompare. This means that string comparisons are case-sensitive: CODICE = "Sal" is different from CODICE = "sal" and from CODICE = "SAL".
If you set CompareMode to vbTextCompare, string comparisons are not case-sensitive: "sal" and "Sal" and "SAL" are seen as the same string.
Whether you want vbBinaryCompare or vbTextCompare depends on what your project requires. You have to decide.
If you set CompareMode to vbTextCompare, string comparisons are not case-sensitive: "sal" and "Sal" and "SAL" are seen as the same string.
Whether you want vbBinaryCompare or vbTextCompare depends on what your project requires. You have to decide.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: sort array from dictionary key
great explain.HansV wrote:The default value of CompareMode is vbBinaryCompare. This means that string comparisons are case-sensitive: CODICE = "Sal" is different from CODICE = "sal" and from CODICE = "SAL".
If you set CompareMode to vbTextCompare, string comparisons are not case-sensitive: "sal" and "Sal" and "SAL" are seen as the same string.
Whether you want vbBinaryCompare or vbTextCompare depends on what your project requires. You have to decide.
Tks.