Help with reading from a text file...

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
OK, So I am having an issue (Not surprising, as this project is VERY ambitious for my merger "skill") I would like to read a comma delimited .txt file, and store the output into a array, so that I may use the data in the rest of the program. Thus far I have failed, and no amount of googleing seems to help, this is what I have so far..Private Sub PROC_Click(sender As Object, e As EventArgs) Handles PROC.Click

Using MyReader As New _
Microsoft.VisualBasic.FileIO.TextFieldParser(INPUTP.Text)
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(",")
Dim currentRow As String()
While Not MyReader.EndOfData
Try
currentRow = MyReader.ReadFields()
Dim currentField As String
For Each currentField In currentRow
MsgBox(currentField) I think this may be the place to put such code..




Next
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message & _
"is not valid and will be skipped.")
End Try
End While
End Using



End Sub
Let me know what you think, I am a noob, so I apologize if this isnt worth anyones time.
Thanks,
JD

View the full article
 
Back
Top