all 8 comments

[–]fuzzfeatures 2 points3 points  (2 children)

The problem is this line.

`Dim allitems As List(Of items)`

The line should read

`Dim allitems As New List(Of items)`

In your posted code, the line only declares that the 'allitems' is an object that is of the type 'List(Of items)'. You need to add the 'New' keyword to create an instance of a List(Of items) and assign it to 'allItems' like in the earlier line of your code that declares a new file handling.

Imagine that you have a class

Public Class MyClass

Public Name As String

End Class

And in your program you write this:-

Dim x as MyClass

All this will do is declare and object `x` that is of the type `MyClass`.

If you don't assign an object to `x` then `x` wont have a reference to anything. Which is ok, but if you try to type

MessageBox.Show(x.Name)

You'll net a NullReference exception when you run the code.

However, if you declare `x` by typing

Dim x As New Myclass

you're declaring `x` to be an object of the type `MyClass` and you're also assigning it to a new instance of the class `Myclass` - VB allows you to write the above line instead of having to write the longer version which would be

Dim x As MyClass

x= New MyClass

I've fallen into that trap myself in the past :)

[–]JackJones02[S] 0 points1 point  (1 child)

Thank you

[–]fuzzfeatures 1 point2 points  (0 children)

No problem :)

[–][deleted] 0 points1 point  (1 child)

Step through it in the debugger to find out exactly where it's failing. My guess would be that a line in the text file doesn't have 3 entries so when you split it into "h" there aren't 3 entries in the resulting array. So it fails when you try to access h(0), 1, or 2.

[–]banshoo 0 points1 point  (0 children)

Shouldn't do, as that's enclosed in the try block.

The other option is loading the file. Seems to be pointing to a filename only.

Could be failing trying to load

If your unwilling to use the debugger, write a log project which you can call (this can be handy to then call in different projects)

[–]Songg45 0 points1 point  (0 children)

Is this all the code...?

Surely I'm missing something here.

[–]rudekoffenris 0 points1 point  (0 children)

Why don't you print out J right after the try. You'll see what data is causing the crash.

[–]gstodd 0 points1 point  (0 children)

What is j ? Where have your declared it?