HELP! VB.NET - Sequential text File into an Array
I need to load the information from a sequential text file into an assay so that I may easily access the information.
Can any one please help me? I am going nuts trying to figure out how to do this. Thank You :confused:
[226 byte] By [
cbenteu] at [2007-11-11 9:52:18]

# 1 Re: HELP! VB.NET - Sequential text File into an Array
Try the following:
Imports System
Imports System.IO
Dim path as String = "C:\myfiles"
Dim StringArrayOfTextLines() As String = File.ReadAllLines(path)
# 2 Re: HELP! VB.NET - Sequential text File into an Array
oops. The path is supposed to be to a file not a directory. It should be something like c:\myfiles\sample.txt
# 3 Re: HELP! VB.NET - Sequential text File into an Array
oops. The path is supposed to be to a file not a directory. It should be something like c:\myfiles\sample.txt
I got it. You have no idea how much you have just helped me out. Been trying to get people to answer that for about 10 hours. Also, the Import command bugged out in VB.Net, but I understood what you were trying to do. I managed to fix it up and make it work like so...
Dim path As String = "Products.txt"
Dim StringArrayOfTextLines() As String = IO.File.ReadAllLines(path)
Which works perfectly. I have a few more questions now. Is there a way to load it into two different Arrays? Every 4 lines there is a price. Is there a way I can load that price into a separate array (Just curious on this one)? Another question is, how do I get a count back on how many items are stored in it? There are 10 books total, and 4 array items for each book (An Item number, the title, a description, and the price). The user selects the items from a combo box, types in the amount of units they want, then the information is pulled from the array and displayed in the listbox. How do I do that without manually telling the program which array holds which piece of information?