How would i go about reading a file line by line that within the Line the values are Delimiated by "

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
How would i go about reading a file Line by Line that within that line The values are delimited by " Example of the data:

<pre>"bob" "cat" "1243"
"steve" dog" "6789"[/code]

<br/>
Ive started this with this code but not sure how to go about the next stage:

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Using MyReader <span style="color:Blue; As <span style="color:Blue; New _
Microsoft.VisualBasic.FileIO.TextFieldParser(<span style="color:Blue; My.Application.Info.DirectoryPath & <span style="color:#A31515; "Records28112011.jd")
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(<span style="color:#A31515; " ")
<span style="color:Blue; Dim currentRow <span style="color:Blue; As <span style="color:Blue; String()
<span style="color:Blue; While <span style="color:Blue; Not MyReader.EndOfData
<span style="color:Blue; Try
currentRow = MyReader.ReadFields()
<span style="color:Blue; Dim currentField <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; For <span style="color:Blue; Each currentField <span style="color:Blue; In currentRow
<span style="color:Blue; Next

<span style="color:Blue; Catch ex <span style="color:Blue; As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox(<span style="color:#A31515; "Line " & ex.Message & _
<span style="color:#A31515; "is not valid and will be skipped.")
<span style="color:Blue; End <span style="color:Blue; Try
<span style="color:Blue; End <span style="color:Blue; While
<span style="color:Blue; End <span style="color:Blue; Using
[/code]
<br/>
Any help would be much appreciated. Thanks in advance


View the full article
 
Back
Top