YodaMerlin 0 Newbie Poster

I am trying to make a program where there are several pictureboxes with different pictures. When i click on one, a new one forms at some location on the form. When i utilize the given code, t gives a system null reference, saying I need to add a "new" statement somewhere. Howe do I do this?, because every nw picture created is an array and arrays seem not to like "new" in the declaration?

Public Class ControlPanel
    'Friend WithEvents MainPict As System.Windows.Forms.PictureBox
    ' Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox

    Dim pic2 As New Integer
    Dim pic3 As New Integer
    Dim pic4 As New Integer
    Dim pic5 As New Integer
    Dim pic6 As New Integer
    Dim pic7 As New Integer
    Dim Picture2Add As New PictureBox
    Const CtrlMask As Byte = 8
   
    Private Sub ControlPanel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      
        pic2 = 2
        pic3 = 2
        pic4 = 2
        pic5 = 2
        pic6 = 2
        pic7 = 2
        ' Panel1.AllowDrop = True
    End Sub
   
    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseClick
        Dim picture2add(pic2) As PictureBox
        With picture2add(pic2)
            .ImageLocation = "C:\Users\Timeless\Documents\Visual Studio 2010\Projects\NodeCreatr\NodeCreatr\Images\greencircle.bmp" 
            .Load()
            .Visible = True
            .Location = New Point(100, 20)
        End With


    End Sub
End Class
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.