' 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 DefaultNamespace
    Public Class MainForm
        Inherits System.Windows.Forms.Form
        Private checkBoxAll(4) As CheckBox
        Private button1 As Button
        Private button2 As Button

        Public Shared Sub Main
            Dim fMainForm As New MainForm
            fMainForm.ShowDialog()
        End Sub

        Public Sub New()
            MyBase.New
            InitializeComponent
        End Sub

        Private Sub InitializeComponent()
            Dim i As Integer
            For i = 0 To 3
                checkBoxAll(i) = New CheckBox
            Next
            button1 = New Button
            button2 = New Button
            SuspendLayout
            For i = 0 To 3
                checkBoxAll(i).Location = New Point(50, 50 + i * 50)
                checkBoxAll(i).Size = New Size(100, 25)
                checkBoxAll(i).Text = "Valg " & (i + 1)
            Next
            button1.Location = New Point(200, 100)
            button1.Size = New Size(50, 25)
            button1.Text = "Set"
            AddHandler button1.Click, AddressOf Button1Click
            button2.Location = New Point(200, 150)
            button2.Size = New Size(50, 25)
            button2.Text = "Clear"
            AddHandler button2.Click, AddressOf Button2Click
            ClientSize = New Size(300, 250)
            For i = 0 To 3
                Controls.Add(checkBoxAll(i))
            Next
            Controls.Add(button1)
            Controls.Add(button2)
            Name = "Main Form"
            Text = "Main Form"
            ResumeLayout(False)
        End Sub

        Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
            Dim i As Integer
            For i = 0 To 3
                checkBoxAll(i).Checked = True
            Next
        End Sub

        Private Sub Button2Click(sender As System.Object, e As System.EventArgs)
            Dim i As Integer
            For i = 0 To 3
                checkBoxAll(i).Checked = False
            Next
        End Sub
    End Class
End Namespace
