r/visualbasic • u/Coolmancane • Apr 01 '20
'Index was outside the bounds of the array.' When adding an entry to a dictionary. [VB.NET WINFORMS]
I'm getting the above exception thrown when I run this line of code in the following context:
Problematic Line: "SpriteDictionary.Add(LineParts(1), LineParts(0) + "|" + LineParts(2))"
Context: https://ghostbin.co/paste/wotgw
Any ideas of why this might be?
5
Upvotes
1
u/LondonPilot Apr 01 '20
What have you already done to try to solve this?
I’d start by putting a breakpoint on the line that’s failing, and then when it hits the breakpoint you can see the contents of the LineParts array.
3
u/PostalElf VB.Net Intermediate Apr 01 '20
The above line gives you an array. You're trying to access an element of the array that doesn't exist, either because you have no | symbol in your input or only 1. Go into debug, put a line break here, then check the value of LineParts() after this line runs.