What i'm trying to do (since I have a total of 16 images and text pieces) is manage them using the following code:
The code should check if the picturebox is showing a gray bar, and if it is, make it blue.
It should also modify the label next to it to show on/off. the label's name is the name of the picturebox + "onoff", for example, the picturebox name is "allowip" and the on/off Label is named allowiponoff.
Private Sub propertiesonoff_Click(sender As System.Object, e As System.EventArgs) Handles allowip.Click,enablequery.Click,dnserrorhandling.Click, ..... Dim sendertxt As Object sendertxt = sender.GetType.Name + "onoff" Dim imgg As Bitmap = My.Resources.sliderbar_grey If sender.Image.Equals(My.Resources.Resources.sliderbar_grey) Then sender.Image = My.Resources.Resources.sliderbar_blue sendertxt.text = "On" ElseIf sender.Image.Equals(My.Resources.sliderbar_blue) Then sender.Image = My.Resources.sliderbar_grey sendertxt.text = "Off" End If End Sub
I've found that I can modify the image if I don't have an "If" statement. as soon as I try to check for the current image in the picturebox, it no longer works. I've tried using "Ctype" and "DirectCast" for the picturbox, but it doesn't work either.
Thanks in advance.