Home > Articles > Programming > Windows Programming

Introduction to Building Forms With Visual Basic.NET

  • Print
  • + Share This
In this sample chapter, author James Foxall presents some of the very basics of forms: Adding them to a project, manipulating their properties, and showing and hiding them using Visual Basic code.
This article is excerpted from Chapter 5, "Building Forms—Part I," of Sams Teach Yourself Visual Basic .NET in 24 Hours (Sams Publishing; ISBN 0672320800), by James Foxall.
This chapter is from the book

With few exceptions, forms are the cornerstones of every Windows application's interface. Forms are essentially windows and the two terms are often used interchangeably. More accurately, "window" refers to what's seen by the user and what the user interacts with, whereas "form" refers to what you see when you design. Forms let users view and enter information in a program. Such information may be text, pictures, graphs—almost anything that can be viewed on the screen. Understanding how to design forms correctly will allow you to begin creating solid interface foundations for your programs.


Visual Basic.NET uses a new forms engine called Windows Forms, which is different from the engine used in previous versions of Visual Basic.

Think of a form as a canvas on which you build your program's interface. On this canvas, you can print text, draw shapes, and place controls with which users can interact. The wonderful thing about Visual Basic forms is that they behave like a dynamic canvas; not only can you adjust the appearance of a form by manipulating what's on it, you can also manipulate specific properties of the form itself.

Some basic properties of form appearance which you will want to manipulate include:

  • Text
  • Height
  • Left
  • Top
  • Width

The capability to tailor your forms, however, goes far beyond these simple manipulations. More complex actions can include:

  • Adding controls to a form
  • Positioning, aligning, sizing, spacing, and anchoring controls
  • Creating intelligent tab orders
  • Creating transparent forms
  • Creating forms that always float over other forms
  • Creating Multiple Document Interfaces

In this article, I'll present some of the very basics of forms—adding them to a project, manipulating their properties, and showing and hiding them using Visual Basic code. Once you have learned these nuts and bolts, you'll be ready for more advanced form techniques.

Changing the Name of a Form

The first thing you should do when you create a new object is give it a descriptive name. Start Visual Basic now (if it's not already running), and create a new Windows Application titled Forms Example. Using the Properties window, change the name of the form to fclsExample. When you need to create a new instance of this form, you'll use this name rather than the default generic name of Form1.

  • + Share This
  • 🔖 Save To Your Account