Yet another question regarding arrays

Joined
Oct 28, 2006
Messages
19
Programming Experience
Beginner
Your all probably sick of seeing my posts by now but can someone tell me why this doesnt work. When i do a break the test has the correct value for the first record in the text file which should meet the criteria but it doesnt put it into rsvp. Also im not sure if its actually reading all the lines in the file. Can someone please help me this is kind of urgent. Please help in my other threads too i really appreciate this

VB.NET:
Dim i AsInteger
Dim RSVP(,) AsString
Dim sr As IO.StreamReader
Dim test2(,)
If IO.File.Exists("NEWRECORD.TXT") Then
sr = IO.File.OpenText("NEWRECORD.TXT")
Dim strA AsString
strA = sr.ReadLine
WhileNot strA IsNothing
Dim test() AsString = strA.Split(","c)
If test.GetValue(6) = "yes" Then
RSVP(i, 0) = test(0)
RSVP(i, 1) = test(1)
RSVP(i, 2) = test(2)
RSVP(i, 3) = test(3)
RSVP(i, 4) = test(4)
RSVP(i, 5) = test(5)
RSVP(i, 6) = test(6)
RSVP(i, 7) = test(7)
RSVP(i, 8) = test(8)
RSVP(i, 9) = test(9)
i += 1
EndIf
strA = sr.ReadLine()
EndWhile
 
Last edited by a moderator:
Hey,

I assume this is crashing on you, as the RSVP array needs some dimensions set. Try setting them to a large value to test this ie dim RSVP (100,10). Also (I'm sure you've got this one sussed) make sure that it really is the sixth element you're looking for when trying to find "yes" remember it's a 0 based array 0,1,2,3,4,5...
I'd suggest looking into using an arraylist (for performance and a lot less hassle!) instead of the array for RSVP. Otherwise look into the redim / redim preserve statement for changing the dimensions at runtime.

Hope this helps.

Regards,

Andy
 
Back
Top