Hello,

I have a project with multiple forms. One form (Form A) contains a panel which contains many other controls. I have another form (Form B) that calls a function in Form A. The function in Form A uses a For Each loop which loops through the controls in Form A and does stuff to them.

Unfortunitely, this isn't working. Any suggestions?

VB Code:
  1. '-----------------------
  2. ' Form B
  3. '-----------------------
  4. Dim Answer As String = MsgBox("Are you sure you want to remove ALL images from the transfer list?", MsgBoxStyle.YesNo)
  5.                 If Answer = vbYes Then
  6.                     frmMain.UploadArray = myImgArray
  7.                     Call frmMain.RemoveAllImages()
  8.                 End If
  9.                 Answer = Nothing
VB Code:
  1. ' -------------------------------------------------------
  2. ' Form A - Referred to in Form B as frmMain
  3. ' -------------------------------------------------------
  4. Public Sub RemoveAllImages()
  5.         If Not UploadArray Is Nothing Then
  6.             'loop througn all controls in Panel1 and set bgcolor to transparent
  7.             Me.Focus()
  8.             Dim pnlCtl As Control
  9.             For Each pnlCtl In Me.Panel1.Controls
  10.                 pnlCtl.BackColor = Color.Transparent
  11.                 pnlCtl.ForeColor = ForeColor.Black
  12.                 pnlCtl.Controls(0).ForeColor = ForeColor.Black
  13.             Next
  14.             ' Clear the upload Array
  15.             UploadArray = Nothing
  16.             'Update View Selected Images Form
  17.             If Not frmViewSelected Is Nothing Then
  18.                 frmViewSelected.myImgArray = UploadArray
  19.                 frmViewSelected.DisplayImageArray(UploadArray)
  20.             End If
  21.             stBarSelImgs.Text = "Selected Images: 0"
  22.             Me.Refresh()
  23.         End If
  24.     End Sub

Thanks for any suggestions.