having a class control a picture in a form

im tring to make a picturebox.visible = false in my form1 by coding it in a class instead of the form. Im sure this is a stupid question but i cant seem to get the class to identify the picturebox, im missing something.
saber2xAsked:
Who is Participating?
 
LektranCommented:
dim ctrl as Control
For Each ctrl in Me.Controls
           If TypeOf ctrl is PictureBox Then
                       ctrl.Visible = False
            End If
Next
0
 
LektranCommented:
Public Sub HidePicture(ByRef pic as PictureBox)
                pic.Visible = False
End Sub

to call:
HidePicture(picturebox)
0
 
saber2xAuthor Commented:
this doesnt quite work, im tring to do like 50 pictures and i want to shrink the code in my form...example im currently doing this picturebox2.visible = false .. .. .. .. picturebox50.visible = false, what i want to do is call a class, and in the class set all the pictures to false...but it doesnt detect my pictures...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.