Lesson 2: Designing the User Interface in VB2019

Learn how to customize forms, set properties at design-time and runtime, and create professional VB applications

Key Takeaway

Designing an effective User Interface (UI) is the crucial first step in Visual Basic 2019 development. This lesson teaches you how to customize forms and controls to create professional, user-friendly applications.

Prior to creating a Visual Basic 2019 project, you need to conceive an idea of what kind of project you intend to develop. Whether it's a desktop game, multimedia app, financial app, or database management app, having a clear vision is crucial.

2.1 Customizing the Default Form

When you start a new Visual Basic 2019 project, the IDE displays the default form along with the Solution Explorer and Properties windows. The Properties window is your central hub for customizing form appearance during design-time.

1 Plan Your Application

Start with a paper sketch to visualize your design before using the VB2019 IDE. Spending 15 minutes sketching can save hours of redesign later.

2 Design in VB2019 IDE

Customize the default form by modifying properties during design-time. Add controls from the toolbox and define their properties.

Visual Basic 2019 IDE interface showing default form
Figure 2.1: Initial Visual Basic 2019 IDE

Understanding the Properties Window

The Properties window comprises an object drop-down list, a list of properties, and a description pane that explains the selected property.

Object List

Drop-down list to select different controls on your form

Properties List

Comprehensive list of properties for the selected object

Description Pane

Detailed explanation of each property's purpose

VB2019 Properties window with form properties
Figure 2.2: The Properties Window

Let's configure these essential properties for Form1:

Property Value Description
Name MyForm Identifier for the form in code
Text My First VB2019 Program Title bar text
BackColor 255, 51, 153 (Pink) Background color
ForeColor White Text color
MaximizeBox False Disables maximize button
Font Arial, 9.75pt Default font for controls

You can select colors from three tabs in the color picker:

Custom color palette in VB2019
Figure 2.3: Custom Palette
Web colors in VB2019
Figure 2.4: Web Colors
System colors in VB2019
Figure 2.5: System Colors
VB2019 runtime interface with custom form
Figure 2.6: The Runtime UI

2.2 Changing Form Properties at Runtime

You can dynamically modify form properties during program execution using code. The default form is represented by the Me keyword:

FormProperties.vb
' Change form properties at runtime
Me.BackColor = Color.Cyan

Example 2.1: Setting Form Properties in Code

FormSetup.vb
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Text = "My First VB2019 Program"
        Me.BackColor = Color.Pink
        Me.MaximizeBox = False
        Me.MinimizeBox = True
    End Sub
End Class

Output:

Example 2.2: Advanced Form Customization

AdvancedForm.vb
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.Text = "My First VB2019 Project"
    Me.BackColor = Color.Beige
    Me.MaximizeBox = False
    Me.MinimizeBox = True
    
    ' Set form size to 400x400 pixels
    Me.Size = New Size(400, 400)
    
    ' Set form opacity to 85%
    Me.Opacity = 0.85
    
    ' Center form on screen
    Me.CenterToParent()
End Sub

Output:

VB2019 form with custom size and opacity
Figure 2.7: Form with Custom Size and Opacity

Lesson Summary

In this lesson, you've learned how to create professional user interfaces in VB2019:

UI Planning

Always sketch your UI design before implementation

Properties Window

The central place for customizing form appearance at design-time

Runtime Customization

Use the Me keyword to modify properties programmatically

Advanced Features

Positioning, sizing, and opacity control for professional interfaces

You've learned how to customize the VB2019 form both at design-time and runtime. In the next lesson, we'll explore how to enhance the UI with various controls and their properties.

Next Lesson

Ready to learn how to enhance the UI? Continue to Lesson 3: Enhancing the UI.

Related Resources

VB6 Tutorial

Mastering VB6 Programming

Explore Tutorials

Visual Basic Examples

Practical VB code samples for real-world applications

View Examples

Excel VBA Tutorial

Learn how to automate Excel by creating VBA macros

Learn More

VB2019 Paperback

Comprehensive guide to Visual Basic 2019

Get on Amazon