can someone help me with this issue i don't see why its not initializing but here is my error:

Object reference not set to an instance of an object.

And Here is My Code:

Dim pic As New PictureBox
    Dim frm As New Form
    Public lbllist As Generic.List(Of Label)
    Public piclist As New Generic.List(Of PictureBox)
    Public txtbox As Generic.List(Of TextBox)
    Private index As Integer

Sub AddLabel(ByVal label_index As Long, ByVal caption As String, ByVal left As Integer, ByVal top As Integer, ByVal customsize As Integer, ByVal customcolor As Integer, ByVal alignment As Byte, ByVal width As Long, ByVal height As Long)
        Dim lblboxer As New Label
        lblboxer.Text = caption
        lblboxer.Left = left
        lblboxer.Top = top
        lblboxer.Font = New Font(lblboxer.Font.FontFamily, customsize)
        lblboxer.ForeColor = Color.Yellow
        lblboxer.TextAlign = ContentAlignment.MiddleCenter
        lblboxer.Width = width
        lblboxer.Height = height
        lbllist.Add(lblboxer)
        frm.Controls.Add(lbllist.Item(label_index))
        AddHandler lbllist.Item(label_index).Click, AddressOf label_Click
    End Sub

and this is what is not initializing for some strange reason in that code(above):

piclist.Add(Picboxer)

Thanks in return,
Stormshell

remove the New from the declaration and inititialise the generic list on load or whenever you start needing it.
btw i cant find piclist.Add(Picboxer) in the code you have posted o.O

>Object reference not set to an instance of an object.
Error describes that you are working on null. Take look into your code and find where you missed New keyword.

U missed new here ::

Dim pic As New PictureBox
    Dim frm As New Form
    Public lbllist As Generic.List(Of Label) 'Insert new here
    Public piclist As New Generic.List(Of PictureBox)
    Public txtbox As Generic.List(Of TextBox)
    Private index As Integer
 
Sub AddLabel(ByVal label_index As Long, ByVal caption As String, ByVal left As Integer, ByVal top As Integer, ByVal customsize As Integer, ByVal customcolor As Integer, ByVal alignment As Byte, ByVal width As Long, ByVal height As Long)
        Dim lblboxer As New Label
        lblboxer.Text = caption
        lblboxer.Left = left
        lblboxer.Top = top
        lblboxer.Font = New Font(lblboxer.Font.FontFamily, customsize)
        lblboxer.ForeColor = Color.Yellow
        lblboxer.TextAlign = ContentAlignment.MiddleCenter
        lblboxer.Width = width
        lblboxer.Height = height
        lbllist.Add(lblboxer)
        frm.Controls.Add(lbllist.Item(label_index))
        AddHandler lbllist.Item(label_index).Click, AddressOf label_Click
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.