Results 1 to 2 of 2

Thread: 'Scuse me! Quick question about parsing!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    99

    Wink

    lets say i've got a .txt file with the following lines in it:

    blah|poop|jim|bob
    stoop|hugme|hi|foo


    (each line is a different set of 4 elements)

    How can I get each line, and parse it to save each element in between the "|"s to a variable?


    Thanks!!
    ___________________________
    Chris

  2. #2
    Hyperactive Member
    Join Date
    May 2000
    Location
    Or
    Posts
    316
    This will place the separate the text and then print the results into a separate file:

    Code:
    Private Sub Command1_click()
    
    Dim FF As Integer
    Dim tmpSplit() As String
    Dim Hold_Variable() As String
    Dim FileName As String, sFile as string
    Dim sLine As String
    Dim x As Integer, y As Integer
    
    FileName = "d:\testf.txt"
    sFile="d:\results.txt"
    
    FF = FreeFile
    
    y = 0
    Open FileName For Input As FF
       While Not EOF(FF)
            Line Input #FF, sLine
            tmpSplit = Split(sLine, "|")
               For x = 0 To UBound(tmpSplit)
                   ReDim Preserve Hold_Variable(y) As String
                   Hold_Variable(y) = tmpSplit(x)
                   y = y + 1
               Next
        Wend
    Close FF
    
    FF = FreeFile
    
    Open sFile For Append As FF
       For x = 0 To UBound(Hold_Variable)
           Print #FF, Hold_Variable(x)
       Next
       
    Close FF
    
    MsgBox "Finished"
    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