' 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 checkBox1 As CheckBox
        Private checkBox2 As CheckBox
        Private checkBox3 As CheckBox
        Private checkBox4 As CheckBox
        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
            checkBoxAll(0) = checkBox1
            checkBoxAll(1) = checkBox2
            checkBoxAll(2) = checkBox3
            checkBoxAll(3) = checkBox4
        End Sub

        Private Sub InitializeComponent()
            checkBox1 = New CheckBox
            checkBox2 = New CheckBox
            checkBox3 = New CheckBox
            checkBox4 = New CheckBox
            button1 = New Button
            button2 = New Button
            SuspendLayout
            checkBox1.Location = New Point(50, 50)
            checkBox1.Size = New Size(100, 25)
            checkBox1.Text = "Valg 1"
            checkBox2.Location = New Point(50, 100)
            checkBox2.Size = New Size(100, 25)
            checkBox2.Text = "Valg 2"
            checkBox3.Location = New Point(50, 150)
            checkBox3.Size = New Size(100, 25)
            checkBox3.Text = "Valg 3"
            checkBox4.Location = New Point(50, 200)
            checkBox4.Size = New Size(100, 25)
            checkBox4.Text = "Valg 4"
            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)
            Controls.Add(checkBox1)
            Controls.Add(checkBox2)
            Controls.Add(checkBox3)
            Controls.Add(checkBox4)
            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
