Sub Sub_CacheImage For Each p As PictureBox In Me.Controls.OfType(Of PictureBox)() p.Visible = False Next p End Sub
Sub Sub_CacheImage For Each p As PictureBox In Me.Controls.OfType(Of PictureBox)().Where(Function(pic) Regex.IsMatch(pic.Name, "img_0[1-8]")) p.Visible = False Next p End Sub
Private mesControles() As Control = { textBox1, pictureBox1, dataGridView1 } Sub Sub_CacheImage For Each c As Control In mesControles c.Visible = False Next c End Sub
Private mLstImages as List(Of PictureBox)=new List(Of PictureBox) mLstImages.Add(img_01) mLstImages.Add(img_02) ... Puis for each lImage in mLstImages lImage.Visible=False Next