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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox sort not as expected 3

Status
Not open for further replies.

HughLerwill

Programmer
Nov 22, 2004
1,818
GB
The following is giving me a mad morning;

List1.Sorted = True set at design time
Code:
Private Sub Command2_Click()

    List1.AddItem "TEKTIPS / MALTON"
    List1.AddItem "TEK-TIPS / MENWITH HILL"
    List1.AddItem "TEKTIPS / MEXBOROUGH"
    List1.AddItem "TEK-TIPS / NAFFERTON"
    List1.AddItem "TEK-TIPS / AMBERLEY"
    List1.AddItem "TEKTIPS / ARUNDEL"

End Sub

The resulting sort is not as expected, the "-" characters seem to be ignored. Results are as expected if I change the "-" characters for another e.g. ".".

Thanks in advance for any help.
 
>Its injection into the discussion made it really unclear what you are after

Not sure I agree. I introduced it because it sounded like Hugh wanted a linguistic comparison. Whilst it is true that in many cases this can indeed be met by changing the case, and then doing a binary comparison, it is not always the case. CompareString gives us the flexibility to do linguistic comparison under various conditions. Sure it has a little more overhead, but it's hardly introducing more complexity.

By providing Hugh with more tools he is better positioned to select the ones the suit his problem best, surely.
 
Well what I was really trying to figure out was what he actually wanted from this sort, and whether he actually did finally get it.
 
...what he actually wanted from this sort
when I start with this;
SourceArray$(1) = "TEKTIPS / MALTON"
SourceArray$(2) = "TEK-TIPS / MENWITH HILL"
SourceArray$(3) = "TEKTIPS / MEXBOROUGH"
SourceArray$(4) = "TEK-TIPS / NAFFERTON"
SourceArray$(5) = "TEK-TIPS / AMBERLEY"
SourceArray$(6) = "TekTips / ARUNDEL"
I want this (and yes I am getting it!);
TEK-TIPS / AMBERLEY
TEK-TIPS / MENWITH HILL
TEK-TIPS / NAFFERTON
TekTips / ARUNDEL
TEKTIPS / MALTON
TEKTIPS / MEXBOROUGH

 
Ok thanks, the upper/lowercase case helps a bit. I just thought there was something more subtle such as a requirement to treat all of the various-length hyphens that exist as equal and so on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top