Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ORDER dictionary element 2

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
423
IT
I fiil this dictionary with;

'COMBO_DATA
If Not MYDIC1.Exists(DATA) Then
MYDIC1.Add DATA, RW + 1
End If

how to order this array?

Note:
DATA is date
 
VB doesn't include a dictionary class, so I presume you are using the vbscript dictionary. If so, afraid it does not have a sort method, so you,ll have to write yourself a sort function. But dictionaries are specifically designed as random access, so if you need sorting, then perhaps it is the wrong class to use. What are you trying to achieve?
 
I read a txt line by line, and get DATA from a Mid, position from each line, to the and of loop, i need to fill a combobox with a ordered DATA.
The string DATA not is ordered during the loop in txt...

Similar:

11/09/2010
14/12/1989
15/12/2011
...
ecc.
 
in VB6, Combo box has Sorted property, but in the tip it says: "Indicates whether the elements of a control are automatically sorted alphabetically". Since it looks like you have Dates to display, that may not work for you :-(

But you can always sort your data by yourself...


---- Andy

There is a great need for a sarcasm font.
 
So you don't actually need a dictionary? That's what I am trying to get at. You just want an array that you can sort? Or is there info missing from your description?

I ask because of it you are just using the ductiobary as a simple array, then you could instead use VB.nets ArrayList with a custom sort comparison function.

And yes, you can use various .net bits and pieces in VB. I've illustrated the idea mentioned above previously in a thread222-1695412; look for my post of 15 Oct 12 19:17
 
>Since it looks like you have Dates to display, that may not work for you

Unless of course the OP is adhering to ISO 8601 ...
 
Oh, the Date format…
Looks like I was years ahead of time while attending high school (a long time ago and far, far away from USA) where – back then - in my notes I did write in the format of 2020-11-19 [thumbsup2]

You know, you could use a Bubble Sort for your dates, or… you can cheat. Let the (other) combo box do the sorting for you.
Have another combo box with the Sort property set to True, populate it with the dates from your text file in the YYYY-MM-DD format, which will put them in the order you want. Then you can use this extra combo box to populate your original combo with the dates in any format you want.
[wiggle]

---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top