' 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 E5
    Public Class MainForm
        Inherits Form

        Private button1 As Button

        Public Sub New()
            MyBase.New
            InitializeComponent
        End Sub

        Private Sub InitializeComponent()
            button1 = New Button
            SuspendLayout
            button1.Location = New Point(100, 100)
            button1.Size = New Size(100, 25)
            button1.Text = "Åben sub form"
            AddHandler button1.Click, AddressOf Button1Click
            ClientSize = New Size(300, 225)
            Controls.Add(button1)
            Text = "Main Form"
            ResumeLayout(false)
        End Sub

        Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
            Dim form2 As New SubForm("Sub Form")
            form2.Show
        End Sub
    End Class

    Public Class SubForm
        Inherits Form

        Public Sub New(title As String)
            MyBase.New
            ClientSize = New Size(100, 100)
            Text = title
        End Sub
    End Class

    Public Class TestClass
        Public Shared Sub Main
            Dim form1 As New MainForm
            form1.ShowDialog()
        End Sub
    End Class
End Namespace
