|
Answer» Hello all! I'm trying to make a program to where when a user inputs their name and selects a color of what they want their name to be will display within the program. But my issue is trying to get a image that is supposed to switch from on to off.
For example, I want the user to have to click on a light bulb to turn on and then click it to turn off...
But at the bottom it will state "Turn off the light, Danny." and when the user clicks on the "on light bulb" it will turn off and then the text will display as "Turn on the light, Danny", and then once they click on the image it will go back to the previous statement to turn off the light.
I'm having difficulties trying to figure out how to go about coding that part. I have everything else, but I'm stuck on how to get the text to change along with the image.
Any ideas?
If you need to see what I have coded so far, please let me know and I'll copy and paste it here along with a screen shot of what the program looks like. Do you mean a status bar? It would help to see what you have so far. Also, is this VB6 or VB.Net?It is Visual Studio .NET 2005 but I have it set for Visual Basic for the IDE Settings. I hope that makes sense?
Here's the coding I have so far.
Code: [Select]Public Class MainForm
PRIVATE Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub RedRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RedRadioButton.CheckedChanged ' Display the current text color and message.
MessageLabel.Text = "Turn on the light, " & NameTextBox.Text MessageLabel.ForeColor = Color.Red
End Sub
Private Sub GreenRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GreenRadioButton.CheckedChanged ' Display the current text color and message.
MessageLabel.Text = "Turn on the light, " & NameTextBox.Text MessageLabel.ForeColor = Color.Green
End Sub
Private Sub BlackRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BlackRadioButton.CheckedChanged ' Display the current text color and message.
MessageLabel.Text = "Turn on the light, " & NameTextBox.Text MessageLabel.ForeColor = Color.Black
End Sub
Private Sub BlueRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BlueRadioButton.CheckedChanged ' Display the current text color and message.
MessageLabel.Text = "Turn on the light, " & NameTextBox.Text MessageLabel.ForeColor = Color.Blue End Sub
Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click ' PRINT the form in the Print PREVIEW window.
PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview PrintForm1.Print() End Sub
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click ' End the program.
Me.Close() End Sub
Private Sub LightOffPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LightOffPictureBox.Click End Sub
Private Sub LightOnPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LightOnPictureBox.Click
End Sub End Class
I have attached what the program looks like when it first runs, and when you PUT in your name... Now you will only see one image, because the other image is behind the off light bulb but.
[Saving space - attachment deleted by admin]Instead of using two image controls you could use just one and alternate the image that is currently displayed in it. You could then add a click event to the image control. Using a boolean variable you could check to see if the light is on. If it's off display the "light on" image and vice versa.
|