VB.NET
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' --- Build a list of all active forms, and display it to the user Dim activeforms As String = String.Empty For Each item As Form In Application.OpenForms activeforms = String.Format("{0}{1}{2}", activeforms, item.Name, vbCrLf) Next MsgBox(String.Format("The names of the active forms are:{0}", activeforms)) ' // End Sub