Value cannot be null.parameter name:item

Last post 07-03-2009 9:47 AM by amit.jain. 1 replies.

Sort Posts:

  • Value cannot be null.parameter name:item

    07-03-2009, 3:50 AM
    • Member
      point Member
    • nandhini.s
    • Member since 07-03-2009, 7:42 AM
    • Posts 1

    hi al..

    am a beginner for vb.net, i was using the WROX book to start of with vb.net.In that i had an example code which i tried to work out but i got an error like this one ,am jus creating an array and adding it into the list

    value cannot be null.Parameter name:item

    plz do help me with ur replies


    dim stname(4) as string

    private sub form1_load() me.load

    stname(0)="naresh"

    stname(0)="ezhil"

    stname(0)="balaji"

    stname(0)="srinath"

    end sub

    private sub btn_click()

    for each n as string in stname

    lstData.Items.Add(n) <-------------------- at tis point am getting the error

    next

    end sub

  • Re: Value cannot be null.parameter name:item

    07-03-2009, 9:47 AM
    Answer
    • Star
      7,932 point Star
    • amit.jain
    • Member since 10-06-2008, 1:09 AM
    • Delhi India
    • Posts 1,264

    Try this code

    Private strName As String() = New String(3) {}
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        strName(0) = "amit"
        strName(1) = "jain"
        strName(2) = "amitjain"
        strName(3) = "amiTjaiN"
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        For Each strTest As String In strName
            ListBox1.Items.Add(strTest)
        Next
    End Sub
    


    Don't say thanks rather mark my reply as "Answer" if it helps you ,Doing so u'll get points too
    amiT jaiN

    ASP.NET C#.NET Articles
Page 1 of 1 (2 items)