Value Cannot Be Null. Paramater Name: item?

justin1552

Hurr Durr
Ok, I've been working on a code for VB2005 that will display book titles and I keep getting an error saying Value cannot be null. Paramater Name: item. I've tried multiple things and none seem to work. Here's my code so far. The line in bold is where I've had the problem. Any help would be appreciated.

'Name: Flick's Book Publishing
'Developer: JDT
'Date: 06/03/2010
Option Strict On
Public
Class frmFlicksPublish
Public Shared _intSizeOfArray As Integer = 17
Public Shared _strInventoryItem(_intSizeOfArray) As String
Private _strItemId(_intSizeOfArray) As String
Private Sub frmFlicksPublish_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim objReader As IO.StreamReader
Dim strLocationAndNameOfFile As String = "J:\Class Information\Lafferty\VB\Chapter 09\warehouse.txt"
Dim intCount As Integer = 0
Dim intFill As Integer
Dim strFileError As String = "The file is not available. Restart when the file is available."
If IO.File.Exists(strLocationAndNameOfFile) = True Then
objReader = IO.File.OpenText(strLocationAndNameOfFile)
Do While objReader.Peek <> -1
_strInventoryItem(intCount) = objReader.ReadLine()
_strItemId(intCount) = objReader.ReadLine()
intCount = +1
Loop
objReader.Close()
For intFill = 0 To 16
Me.lstBooks.Items.Add(_strItemId(intFill))
Next
Else
MsgBox(strFileError, , "Error")
Me.Close()
End If
End Sub
Private Sub btnComputeInventory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click


End Sub
Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click
Application.Exit()
End Sub
Private Sub mnuClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClear.Click
Me.lstBooks.Items.Clear()
End Sub
End
Class
 
I would reccommend looking at your class definition. If you do not initialize the values contained in the class to something, your compiler or runtime environments may be stumbling on an unasssigned variable. When a class is created, in most cases, all fields contained in the class will be assigned null values as placeholders until your code has a chance to initialize them. You may also want to check your inheritances. Most of my coding has been in assembler C, and C++. Hope that helps.
 
Back
Top