Try these steps:
Step 1: First off let us start with a blank project for learning purposes.
So start by creating a new project and name it what ever you want.
After the project loads, proceed to step 2.
Step 2: Go ahead and add a second form to your project. Maybe call this form frmColorPicker. On frmColorPicker, Add the number of pictureboxes you want for the color palette and set their BackColor properties to the desired colors.
-Double click any of the PictureBoxes to bring up the Code Editor. You will notice that it will bring up the PictureBoxes's Click Handler.
-On the line where it says Private Sub Picturebox_Click.....Handles...
we are going to tell the parser that this Sub Procedure will handle more than one object's click event by appending each object name separated by a comma
Private Sub PictureBox1_Click(sender As Object, e As System.EventArgs) Handles PictureBox1.Click, PictureBox2.Click
ActivePbox.BackColor = sender.backcolor
Me.Close()
End Sub
-Also while we are in the code editor, Go ahead and add the code below
Dim ActivePbox As PictureBox
Public Function SelectColor(PictureboxToChange As PictureBox)
ActivePbox = PictureboxToChange
Me.ShowDialog()
End Function
-And add the code from the click event handler from above inside the picturebox's click event handler.
Step 3: Go back to Form1. Add the pictureboxes you want to the form.
-Double click one of the pictureboxes to open the code editor. You will notice again that the click event handler will be there. Go ahead and append the other pictureboxes like you did in step 2.
-Here we will add the following code.
frmColorPicker.SelectColor(sender)
----------------------------------------------------------------------------------
CHECK YOUR CODE:
Form1 code should look similar to the following code:
Public Class Form1
Private Sub PictureBox1_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox1.Click, PictureBox2.Click, PictureBox3.Click, PictureBox4.Click
frmColorPicker.SelectColor(sender)
End Sub
End Class
frmColorPicker code should look similar to the following code:
Public Class frmColorPicker
Dim ActivePbox As PictureBox
Public Function SelectColor(PictureboxToChange As PictureBox)
ActivePbox = PictureboxToChange
Me.ShowDialog()
End Function
Private Sub PictureBox1_Click(sender As Object, e As System.EventArgs) Handles PictureBox1.Click, PictureBox2.Click
ActivePbox.BackColor = sender.backcolor
Me.Close()
End Sub
End Class
----------------------------------------------------------------------------------
Does this help you to do what you are wanting?