Automatically generated user interface code

The Visual Studio development system automatically generates the VB code to create your user interface. The following is a portion of the form1.vb file that was created when I wrote the First VB program.

     Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button1.Location = New System.Drawing.Point(66, 76)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(160, 120)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Nothing happens when you click this button"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1})
        Me.Name = "Form1"
        Me.Text = "First VB program"
        Me.ResumeLayout(False)
    End Sub
When you write your program, you are actually creating a new class, and when you run the program, VS.NET automatically creates an instance of that class and executes it. That new object is called Me, and it contains a Button called Button1. This automatically generated code assigns values to the properties of Button1 that I changed while creating the user interface. If you do not change the value of a property, it inherits a default value automatically.

Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.