Hello. I'm working on a project that loads information from a csv file into an arraylist. I am also calculating the string lenght of each item on the arraylist and adding the lenght values together for other functions of my program. Everything works fine until my code reaches a certain point and I get an error:
"Index was outside the bounds of the array."
Here is a sample of the code that generates that error:
Can somebody help me understand what I'm doing wrong? Or is there another way to trim my code down and still make it do the same thing?
Thank you in advance...
"Index was outside the bounds of the array."
Here is a sample of the code that generates that error:
B4X:
Sent1 = ArrayRefLoad.Item(0)
Lenght1 = StrLength (Sent1)
P1S = 0
P1E = Lenght1
Sent2 = ArrayRefLoad.Item(1)
Lenght2 = StrLength (Sent2)
P2S = Lenght1
P2E = Lenght2 + Lenght1
Sent3 = ArrayRefLoad.Item(2)
Lenght3 = StrLength (Sent3)
P3S = P2E
P3E = Lenght3 + Lenght1 + Lenght2
Sent4 = ArrayRefLoad.Item(3)
Lenght4 = StrLength (Sent4)
P4S = P3E
P4E = Lenght4 + Lenght1 + Lenght2 + Lenght3
Sent5 = ArrayRefLoad.Item(4)
Lenght5 = StrLength (Sent5)
P5S = P4E
P5E = Lenght5 + Lenght1 + Lenght2 + Lenght3 + Lenght4
'''''''''''my code keeps increasing in this same rithm until it reaches this point:
Sent39 = ArrayRefLoad.Item(38)
Lenght39 = StrLength (Sent39)
P39S = P38E
P39E = Lenght39 + Lenght1 + Lenght2 + Lenght3 + Lenght4 + Lenght5 + Lenght6 + Lenght7 + Lenght8 + Lenght9 + Lenght10 + Lenght11 + Lenght12 + Lenght13 + Lenght14 + Lenght15 + Lenght16 + Lenght17 + Lenght18 + Lenght19 + Lenght20 + Lenght21 + Lenght22 + Lenght23 + Lenght24 + Lenght25 + Lenght26 + Lenght27 + Lenght28 + Lenght29 + Lenght30 + Lenght31 + Lenght32 + Lenght33 + Lenght34 + Lenght35 + Lenght36 + Lenght37 + Lenght38
'Sent40 = ArrayRefLoad.Item(39)
'Lenght40 = StrLength (Sent40)
'P40S = P39E
'P40E = Lenght40 + Lenght1 + Lenght2 + Lenght3 + Lenght4 + Lenght5 + Lenght6 + Lenght7 + Lenght8 + Lenght9 + Lenght10 + Lenght11 + Lenght12 + Lenght13 + Lenght14 + Lenght15 + Lenght16 + Lenght17 + Lenght18 + Lenght19 + Lenght20 + Lenght21 + Lenght22 + Lenght23 + Lenght24 + Lenght25 + Lenght26 + Lenght27 + Lenght28 + Lenght29 + Lenght30 + Lenght31 + Lenght32 + Lenght33 + Lenght34 + Lenght35 + Lenght36 + Lenght37 + Lenght38 + Lenght39
Can somebody help me understand what I'm doing wrong? Or is there another way to trim my code down and still make it do the same thing?
Thank you in advance...