Results 1 to 4 of 4

Thread: Need help sorting strings

  1. #1

    Thread Starter
    New Member Yankeepop's Avatar
    Join Date
    Jan 2010
    Location
    Henderson, NC - USA
    Posts
    5

    Need help sorting strings

    I wrote a membership program for our local senior center but I can't figure out how to create a alphabetized file so I can send it to a printer.

    For instance:

    File Names.dat contains
    Mary
    Jack
    Sally
    Andrew

    I need to create a new alphabetized file.

    I know a simple bubble sort routine will do this but I don't know how to do it. Can someone please help me? I'm using VB5.0

  2. #2

  3. #3
    Addicted Member Optional's Avatar
    Join Date
    Jan 2010
    Location
    Rudimentary Space
    Posts
    214

    Re: Need help sorting strings

    I added a commandbutton on a new form and added the follwowing code to the commandbutton:
    Code:
    Private Sub Command1_Click()
        Shell "Sort C:\FileA.txt /O C:\FileB.txt"
    End Sub
    That will work on windows 2000, XP and VISTA.
    I created FileA.txt with content:
    Mary
    Jack
    Sally
    Andrew

    I then executed the code and it created FileB with the follwing content:
    Andrew
    Jack
    Mary
    Sally

    Edit
    The above code obviously assumes your original file already existed e.g.: Names.dat.



    Kind Regards,
    Optional



    If you feel this post has helped in answering your question please return the favour and Rate this post.
    If your problem has been solved and your question has been answered mark the thread as [RESOLVED] by selecting the Thread Tools menu option at the top and clicking the Mark Thread Resolved menu item.


    VB6 - (DataGrid) Get the Row selected with the right mouse button



  4. #4

    Thread Starter
    New Member Yankeepop's Avatar
    Join Date
    Jan 2010
    Location
    Henderson, NC - USA
    Posts
    5

    Re: Need help sorting strings

    Thanks RhinoBull, I didn't know it was that easy. As they say, "If you don't use it you lose it" The program I'm creating is the first since I retired 10 years ago so I'm fumbling my way through it.

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