so im making the project and there is two pictures one that shows a light bulb on and the other is off. ur suppose to be able to type ur name in a text box and it will display turn on the light, what u type and turn off the light and also u can change the color. by im having a problem getting the pictures to sit on top of each other to look like ur switching between light on and off, heres my code and attach is how it looks so far. any tips or suggestions plz.

Public Class Form1

Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
'Exit the project.

Me.Close()
End Sub

Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click
'Print the form on the printer

PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
PrintForm1.Print()
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NameBox.TextChanged

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MessageForPicture.Text = "Turn off the light, " & NameBox.Text()

End Sub

Private Sub PictureBoxLightOn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBoxLightOn.Click
MessageForPicture.Text = "Turn off the light, " & NameBox.Text()

End Sub

Private Sub BlackButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BlackButton.CheckedChanged
MessageForPicture.ForeColor = Color.Black

End Sub

Private Sub BlueButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BlueButton.CheckedChanged
MessageForPicture.ForeColor = Color.Blue
End Sub

Private Sub RedButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RedButton.CheckedChanged
MessageForPicture.ForeColor = Color.Red
End Sub

Private Sub GreenButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GreenButton.CheckedChanged
MessageForPicture.ForeColor = Color.Green
End Sub

Private Sub PictureBoxLightOff_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBoxLightOff.Click
MessageForPicture.Text = "Turn on the light, " & NameBox.Text()

End Sub
End Class

Do you have two picture boxes? There wasn't anything in your code about picture boxes or images?

Use only one picture box and load the image you need

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    '
    PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

  End Sub

  Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    '
    PictureBox1.Image = Image.FromFile("C:\BulbOn.jpg")

  End Sub

  Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
    '
    PictureBox1.Image = Image.FromFile("C:\BulbOff.jpg")

  End Sub

Instead of loading images from the files, you can set images as resources.

This article has been dead for over six months. Start a new discussion instead.