The Complete Form Class (ctd.)
Now deep breath it’s time for the Constructor or the New procedure. This runs
when a new instance of the form is created.
Public Sub New()
MyBase.New()
Me.cbCancel = New System.Windows.Forms.Button()
Me.cbAccept = New System.Windows.Forms.Button()
Me.txtEnteredText = New System.Windows.Forms.TextBox()
Me.lblEnterText = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'cbCancel
'
Me.cbCancel.Anchor = (System.Windows.Forms.AnchorStyles.Bottom
Or System.Windows.Forms.AnchorStyles.Right)
Me.cbCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.cbCancel.Location = New System.Drawing.Point(204,
108)
Me.cbCancel.Name = "cbCancel"
Me.cbCancel.TabIndex = 3
Me.cbCancel.Text = "Cancel"
'
'cbAccept
'
Me.cbAccept.Anchor = (System.Windows.Forms.AnchorStyles.Bottom
Or System.Windows.Forms.AnchorStyles.Right)
Me.cbAccept.Location = New System.Drawing.Point(112,
108)
Me.cbAccept.Name = "cbAccept"
Me.cbAccept.TabIndex = 2
Me.cbAccept.Text = "Accept"
'
'txtEnteredText
'
Me.txtEnteredText.Anchor = (System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Right)
Me.txtEnteredText.Location = New System.Drawing.Point(132,
24)
Me.txtEnteredText.Name = "txtEnteredText"
Me.txtEnteredText.TabIndex = 1
Me.txtEnteredText.Text = "TextBox1"
'
'lblEnterText
'
Me.lblEnterText.Location = New System.Drawing.Point(20,
28)
Me.lblEnterText.Name = "lblEnterText"
Me.lblEnterText.Size = New System.Drawing.Size(100,
16)
Me.lblEnterText.TabIndex = 0
Me.lblEnterText.Text = "Enter Text:"
Me.lblEnterText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'frmMain
'
Me.AcceptButton = Me.cbAccept
Me.AutoScaleBaseSize = New System.Drawing.Size(6,
14)
Me.CancelButton = Me.cbCancel
Me.ClientSize = New System.Drawing.Size(292, 153)
Me.Controls.AddRange(New System.Windows.Forms.Control()
{Me.lblEnterText, Me.txtEnteredText, Me.cbAccept,
Me.cbCancel})
Me.Font = New System.Drawing.Font("Verdana", 8.25!,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.MinimumSize = New System.Drawing.Size(200, 100)
Me.Name = "frmMain"
Me.Text = "Forms and Controls"
Me.ResumeLayout(False)
End Sub
A lot of interesting code in there which sets the all the properties of the controls
to exactly what we set them to in the VS.Net designer. No other properties are
mentioned because they were left at the defaults.