Results 1 to 2 of 2

Thread: Text (.txt) question, please view

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Location
    England
    Posts
    29

    Text (.txt) question, please view

    hi, i need to make a VB program which will open a text file (Names.txt), and delete all the words after the character ":", and also remove every second line...like:
    Before
    Adrian : bla bla bla bla

    Asllani : tri li la

    After
    Adrian
    Asllani
    ....
    please someone give me some ideas...on how to go about doing this...thanks....

  2. #2
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    how about

    VB Code:
    1. Option Explicit
    2. Dim myArray() As String
    3. Dim strString
    4. Dim strString2
    5.  
    6. Private Sub Form_Load()
    7. Open "c:\temp\Names.txt" For Input As #1
    8.  
    9. Do While Not EOF(1)
    10.     Input #1, strString
    11.     If strString <> "" Then
    12.    
    13.         myArray = Split(strString, ":")
    14.         strString2 = strString2 & myArray(0) & vbCrLf
    15.        
    16.     End If
    17.    
    18. Loop
    19.  
    20. Close #1
    21.  
    22.  
    23. Open "c:\temp\results.txt" For Output As #1
    24.     Print #1, strString2
    25. Close #1
    26. End Sub

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