I have declared a 2 dimensional, 12 row, 2 column array named strVenues(11,1) in the public section of the form.
I did get it to add only the first field in the record, but I cannot figure out how to get it to add all of the records from the file into the array! There are 11 records in the file, "venues.txt":
Paula Dean Cooking,E
I don't know why the instructions say to create a 12 row array, when there are 11 records. Could that be part of the problem?
I think this is how you put just the first field into the array, as I am required to do. (so why do I need a 2d array if we only add the first field?) I'm so confused!
I also have to populate a list box with just the first field, but I don't know if the information is supposed to come from the array or from the text file.
Why do I need an array if I can just read the text file into the list box?
Can you tell me where the error(s) is/are in my code?
Private Sub readFile() 'reads file into an array 'declare variables Dim sreReader As IO.StreamReader 'open the file sreReader = IO.File.OpenText("venues.txt") 'read each record into the array until the array is filled Dim strVen As String, intIndex, intCount As Integer For intCount = 0 To 10 strVen = sreReader.ReadLine() strVenues(intCount, 0) = strVen.Substring(0, strVen.IndexOf(",")) intIndex = strVen.IndexOf(",") + 1 strVenues(intCount, 1) = strVen.Substring(intIndex) Next intCount sreReader.Close()
I have tried for hours and hours, for several days, to figure this out! I watched the class lectures, studied the book and searched online, and tried different things with the code, but nothing works!!! Please help me figure this out!
Could it have something to do with the way I have used the intIndex and substring methods?
Any clue as to what I'm doing wrong will be most appreciated!
p.s. this is Visual Basic.NET 2003
This post has been edited by OliveOyl3471: 11 July 2007 - 11:21 PM