Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' check to see if any of these controls are
' in panel1
MsgBox(InPanel("button1").ToString)
MsgBox(InPanel("button2").ToString)
MsgBox(InPanel("label1").ToString)
MsgBox(InPanel("label2").ToString)
End Sub
Private Function InPanel(ByVal Ctext As String) As Boolean
Dim n As Boolean = False
For Each j As Control In Me.Panel1.Controls
If j.Name.ToUpper = Ctext.ToUpper Then
n = True
End If
Next
Return n
End Function
End Class