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!!
Printable View
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!!
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