CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2012
    Posts
    2

    Sort nodes in a Treeview or ASCII Tab file?

    Hello:
    I have been asked to tackle a task in VB6 that is a little beyond my skills and am hoping someone here can help me out.

    I have a treeview control and I need to scramble the level based on the last 4-8 digits(I have also figured out how to save this to an ASCII tab file. I don't know if that would be easier to manipulate) . The left side of the tree would stay the same, just the digits on the right side of the tree would be scrambled.
    To briefly give you a view this is a sample of what the treeview might look like.
    A 044765
    -AA 054765
    --AAA 154766
    ----AAA1 154076
    ----AAA2 154176
    ----AAA3 154276
    ----AAA4 154376
    ----AAA5 154476
    ----AAA6 154576
    ----AAA7 154676
    ----AAA8 154006
    ----AAA9 154106
    ----AAA10 154206
    --AAB 154767
    --AAC 154760
    --AAD 154761
    -AB 154664
    -AC 154651
    I need to start at the outer level and scramble based on the digits at the end. In this case the last 6 digits. So in this case I might get something like:
    A 044765
    -AA 054765
    --AAA 154766
    ---AAA1 154376
    ---AAA2 154106
    ---AAA3 154676
    ---AAA4 154076
    ---AAA5 154206
    ---AAA6 154006
    ---AAA7 154476
    ---AAA8 154576
    ---AAA9 154176
    ---AAA10 154276
    --AAB 154767
    --AAC 154760
    --AAD 154761

    Then go up to the next level and then scramble it was well. Perhaps getting something like this:
    A 044765
    -AA 054765
    --AAA 154760
    ---AAA1 154376
    ---AAA2 154106
    ---AAA3 154676
    ---AAA4 154076
    ---AAA5 154206
    ---AAA6 154006
    ---AAA7 154476
    ---AAA8 154576
    ---AAA9 154176
    ---AAA10 154276
    --AAB 154761
    --AAC 154767
    --AAD 154766

    Continue up the levels until you reach the upper most node.

    I have worked on this and have these values sitting in a treeview called TreeView1 and have also been able to save this to an ASCII tab file. I am not sure if it would be easier to modify the ASCII file, then read into the control. Or make the updates directly to the tree.

    The values in each node is one string so to figure out the number of numeric digits to the right, I assume you would have to read from the right until you hit a space. The length would be the same for all values within the tree. So if the first value is determined to be 6 digits long, then all the scrambling should be performed on six digits for all the nodes.

    I have attached a copy of the ASCII tab file just in case it is easier to modify the file directly.

    I realize this is a lot of ask and I really appreciate any help you can provide. I am not very familiar with VB so ideally something that I could just plug into the existing code would be much appreciated.

    To add one more twist if the node starts with an asterick, it should be sorted to the bottom of the level. staying within the group. That is if the value is currently under AA, it should remaining within AA, just moved to the bottom. If this last part is too much to ask, I can work on it at another time. The main think right now is scrambling the values.

    Thank you in advance. I don’t know if we can offer payment for help, if so, that is a possibility.

    Thanks again, and merry Christmas.
    Kp
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Sort nodes in a Treeview or ASCII Tab file?

    Probably best to start by loading it into a database, if you want to keep track of the DATA....
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Dec 2012
    Posts
    2

    Re: Sort nodes in a Treeview or ASCII Tab file?

    Thanks,
    But can you help with a specific example?

    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Sort nodes in a Treeview or ASCII Tab file?

    Export it from whatever app collects it, change what the app produces (add the ',' separation character), or write a separate step to parse the spaces, and insert the separators. Then, you can just IMPORT them, or call directly using SQL. Pretty hard to parse what you have, as it has tabs and EndLine chars.

    Code:
    A,044765,AA,054765
    , ,AAA,154766
    , , ,*,154076*
    But, Add the column names for each one
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured