' 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 Form
        Private a262 As CheckBox
        Private a263 As CheckBox
        Private a261 As CheckBox
        Private a264 As CheckBox
        Private button1 As Button

        Public Sub New()
            InitializeComponent
        End Sub

        <STAThread()> _
        Public Shared Sub Main(ByVal args As String())
            Application.Run(New MainForm)
        End Sub

        Private Sub InitializeComponent()
            button1 = New Button
            a261 = New CheckBox
            a263 = New CheckBox
            a262 = New CheckBox
            a264 = New CheckBox
            SuspendLayout
            button1.Location = New Point(50, 450)
            button1.Size = New Size(300, 50)
            button1.Name = "button1"
            button1.Text = "Set"
            AddHandler button1.Click, AddressOf Button1Click
            a261.Location = New Point(50, 50)
            a261.Name = "a261"
            a261.Text = "#1"
            a262.Location = New Point(50, 150)
            a262.Name = "a262"
            a262.Text = "#2"
            a263.Location = New Point(50, 250)
            a263.Name = "a263"
            a263.Text = "#3"
            a264.Location = New Point(50, 350)
            a264.Name = "a264"
            a264.Text = "#4"
            ClientSize = New Size(400, 550)
            Controls.Add(button1)
            Controls.Add(a264)
            Controls.Add(a263)
            Controls.Add(a262)
            Controls.Add(a261)
            Name = "MainForm"
            Text = "Main Form"
            ResumeLayout(False)
        End Sub

        Sub Button1Click(ByVal sender As Object, ByVal e As System.EventArgs)
            For Each c As Control In Controls
                If TypeOf c Is CheckBox Then
                    If c.Name.IndexOf("a26") = 0 Then
                     CType(c, CheckBox).Checked = True
                    End If
                End If
            Next
        End Sub
    End Class 
End Namespace
