×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

ORDER dictionary element
2

ORDER dictionary element

ORDER dictionary element

(OP)
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

RE: ORDER dictionary element

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?

RE: ORDER dictionary element

(OP)
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.

RE: ORDER dictionary element

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 sad

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


---- Andy

There is a great need for a sarcasm font.

RE: ORDER dictionary element

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: ListBox sort not as expected; look for my post of 15 Oct 12 19:17

RE: ORDER dictionary element

>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 ...

RE: ORDER dictionary element

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close