Results 1 to 2 of 2

Thread: Alphabetical order..?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Arrow Alphabetical order..?

    I want to be able to select a list with my program (located on my computer), push the "go" command button, and have my program to the following... if it finds a line in this txt document that has two or more underscores (__) in it (no matter where in the line), then add the whole line to a NEW text document... or, if the program has an underscore in the front (_) then add the whole line to the text document. OR if it has an underscore at the end (_) then add the whole line to the text document. So, for example, the text document will consist as follows:


    asdfadsf_
    asdfsdfdsf_346
    _asdfasdf
    asdfasd__235
    asdfdsfasfd____2353


    If that was what was in the text document, then it would take the following out and add them all to a new text document:

    asdfadsf_
    _asdfasdf
    asdfasd__235
    asdfdsfasfd____2353

    EXCLUDING the asdfsdfdsf_346 as it does not follow what i wrote at the beginning... If anyone could help me write this then that would be great
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Alphabetical order..?

    Add CommandButton to your Form and name it "go":
    VB Code:
    1. Private Sub go_Click()
    2.     Dim cf As String, nf As String
    3.     Dim ff As Integer: ff = FreeFile
    4.         Open "c:\test.txt" For Input As #ff
    5.             Do Until EOF(ff)
    6.                 Line Input #ff, cf
    7.                     If Left(Trim(cf), 1) = "_" Or Right(Trim(cf), 1) = "_" Or InStr(1, cf, "__") Then
    8.                         nf = nf & cf & vbCrLf
    9.                     End If
    10.             Loop
    11.         Close #ff
    12.     If Len(nf) Then nf = Left(nf, Len(nf) - 2)
    13.     ff = FreeFile
    14.         Open "c:\test_output.txt" For Output As #ff
    15.             Print #ff, nf;
    16.         Close #ff
    17. End Sub
    Post back if you need further explanation.

    Btw... what has all this got to do with the thread title??

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