' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Namespace MyFormProject
    Class MainForm
    Inherits Form
        Private txtbx As TextBox
        Private cmbbx As ComboBox
        Private chkbx As CheckBox
        Private all As Control()
        Private btn As Button
        Public Sub New()
            txtbx = New TextBox 
            txtbx.Location = New Point (100, 100)
            cmbbx = New ComboBox 
            cmbbx.Location = New Point (100, 200)
            cmbbx.Items.Add("aaa")
            cmbbx.Items.Add("bbb")
            cmbbx.Items.Add("ccc")
            chkbx = New CheckBox 
            chkbx.Location = New Point (100, 300)
            all = New Control(2)  {txtbx, cmbbx, chkbx}
            btn = New Button 
            btn.Text = "Toggle visibility"
            btn.Location = New Point (225, 300)
            btn.Size = New Size (150, 25)
            AddHandler btn.Click, AddressOf ClickHandler
            ClientSize = New Size (400, 400)
            Controls.Add(txtbx)
            Controls.Add(cmbbx)
            Controls.Add(chkbx)
            Controls.Add(btn)
            Text = "Visibility test"
        End Sub
        Private Sub ClickHandler(ByVal o As Object, ByVal e As EventArgs)
            Dim i As Integer
            For i = 0 to all.Length-1
                all(i).Visible = Not all(i).Visible
            Next
        End Sub
        <STAThread()> _
        Public Shared Sub Main(ByVal args As String())
            Application.Run(New MainForm )
        End Sub
    End Class 
End Namespace
