2 Replies - 7514 Views - Last Post: 24 February 2010 - 02:31 AM Rate Topic: -----

#1 Jay V.  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 62
  • Joined: 17-November 09

Value Cannot Be Null Parameter: Item

Posted 24 February 2010 - 01:17 AM

I tried to execute a code that will display Book Titles in alphabetical order within a list box
and received an ArgumentNullException (Value cannot be null. Parameter name: item) error.

  Dim strBook As String

        Array.Sort(_strBookTitle)

        For Each strBook In _strBookTitle
            Me.lstDisplay.Items.Add(strBook)
        Next 

This post has been edited by Jay V.: 24 February 2010 - 01:19 AM

Is This A Good Question/Topic? 0
  • +

Replies To: Value Cannot Be Null Parameter: Item

#2 Luc001  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 617
  • Joined: 04-May 09

Re: Value Cannot Be Null Parameter: Item

Posted 24 February 2010 - 02:00 AM

Hi,

The ArgumentNullException means that it can't find the file.
_strBookTitle what is it and where is it.

Here's an example how you can do it with a textfile:

Dim a As String = My.Computer.FileSystem.ReadAllText("path and nameoftextfile.txt")        
Dim b As String() = a.Split(vbNewLine)        
ListBox1.Items.AddRange(B)/>

This post has been edited by Luc001: 24 February 2010 - 03:13 AM

Was This Post Helpful? 0
  • +
  • -

#3 remorseless  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 29
  • View blog
  • Posts: 129
  • Joined: 08-August 09

Re: Value Cannot Be Null Parameter: Item

Posted 24 February 2010 - 02:31 AM

Actually, I believe the error is that one of the book title is null or empty. If you want a quick work around for that then try this code
Dim strBook As String

Array.Sort(_strBookTitle)

For Each strBook In _strBookTitle
        'The book title is not null or empty'
        If Not String.IsNullOrEmpty(strBook) Then
                Me.lstDisplay.Items.Add(strBook)
        End If
Next



Try that and see what happens. Forgive me if it doesn't work, I haven't used VB.Net in a while. Hope I helped ;)

This post has been edited by remorseless: 24 February 2010 - 02:36 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1