Consulting

Results 1 to 3 of 3

Thread: Sorting a list

  1. #1
    VBAX Regular
    Joined
    Apr 2010
    Posts
    28
    Location

    Sorting a list

    I have a project which offers up a list of names from which the user can select one for inclusion in a paragraph of text.

    The names are displayed in a comb-box. If the name the user wants isn't there, he can type a new one. He is then offered the chance to save it so that it will be there the next time.

    The names are saved out to a simple data file.

    When the names are read in to populate the combo box, I want them to be sorted on the surname.

    The problem is picking out the surname!

    A sample (short) list would be:

    Mr. Dingle JP
    District Judge Freda Bloggs
    District Judge Edwards
    District Judge Fred Bloggs OBE
    His Honour Judge Williams QC
    Mrs. Dingle
    Mr. Christopher Snuff-Bowlstrother JP TD
    Miss Marjorie Dingle JP

    I don't want to make the user enter the surname as a separate item if I can help it, but I am not sure that I can help it.

    So far, all I can think of is testing each string for spaces (starting at the end and working backwards). Then check the captured substring for discards (TD, JP, OBE etc) and keep checking backwards until the text has something in it other than a two to three letter discard.

    I am open to better suggestions!

    TIA

    Geoff

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    In the absence of regularity an algorithm that assumes regularity won't be available.

  3. #3
    VBAX Regular
    Joined
    Apr 2010
    Posts
    28
    Location
    Sigh.

    I guess I knew that. I just didn't want to admit it to myself :-)

    Geoff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •