Hot-Link Menu in Right-Side Column

Last Updated 6-30-2010

  • More Computers
  • More Games
  • More Electronics
  • More Books
  • More Software
  • Multiform Projects

    It is very common to have a Windows application with mulitple Forms. Additional Forms are used for various reasons. For example, a splash form may be displayed while the main form is being loaded into the memory. A Form may also be used to display the instructions about a program, or to display the program's output. Each additional Form has its own Graphical User Interface (GUI) as well as its own Code Window. The Form object has methods that facilitate moving from one Form to another during program execution. It is easy to add additional Forms to a VB.Net project. In the following sections we explain how to add additional forms to a project, and how to navigate between them.

    It is always a good idea to save your work every few minutes. Selecting the option to Save All will save all Forms, Code and properties of the current open project to disk. To Save all the work you have done so far select: File ==> Save All from the Visual Studio File Menu tool bar as indicated in the following diagram:

    File Save All

    Figure MFP-1: Visual Basic File Save All

    Buy from Centurion

    When the program is running, we can display the different forms by using the Visual Basice Form Methods(). These methods are called out at the time we want to display a different Form. The next section describes some of these methods and how to use them.

    Visual Basic Form Object Methods

    The Visual Basic Form is created in Visual Studio as a class. A class is a programming construct that contains both data (properties such as height and width of form) as well as methods (actions such as hide or display).

    When we double-click on a blank area of a Visual Basic Form, the code window associated with that form is displayed in our Visual Studio IDE. If you double-click on a blank area of the Form2 object that we just created, Visual studio brings up the following Code Window:

    Form Code Window

    Figure MFP-2: Visual Basic Form Code Window

    Help Support this site - Click this ad

    This is all of the code associated with our Form object before we have added any controls, events or procedures to the form:

    • Public Class Form2: Beginning of code.
      • Public: The Public Keyword means the form itself is accessible to all other forms.
      • Class: The Form is a type of a programming structure called a Class.
      • Form2: The name property of this form.

    • Private Sub Form2_Load: Sub called out when the Form2 is called from another part of the program.
      • Private: Variables and Data in this Sub are only accessible from this code window.
      • Sub: A series of actions that returns no data or information to the calling routine.
      • Form2_Load: This Sub is called by the Load Event in another Form.

    • End Sub: Last line of Sub. Control is returned to Visual Basic.
    • End Class: Last Line of Code associated with this form.

    Visual Basic Show( ) Method

    The Show() method is used to display a Form on the screen as a Modeless Form. A modeless Form can be displayed and accessed at the same time other Forms are displayed. A modeless form does not have to be closed before working on another Form in the program.

    Example: Form2.Show( )

    Help Support this site - Click this ad

    Visual Basic ShowDialog( ) Method

    The ShowDialog() method is used to display a Form on the screen as a Modal Form. A Modal Form can only be accessed when it is the only active Form on the screen. In order to access another Form, the Modal Form must be closed.

    Example: Form2.ShowDialog( )

    Visual Basic Form Close( ) Method

    The Visual Basic Close method is used to remove a From from the computer display, as well as removing the Form from memory, where all data on the Form will be lost.

    Example: Me.Close( )

    Visual Basic Form Accept Button( ) Method

    The Visual Basic Accept Button method is used to program a button as a response for when the user presses the <ENTER> key. This feature helps makes forms more user friendly by providing an action when the user presses the <ENTER> key, such as when they are finished entering data on the form.

    Example: Form2.AcceptButton( )=btnAcceptButton

    Help Support this site - Click this ad

    Visual Basic Multiform Project Example

    Have you ever had a pet named by a previous owner that just didn't seem to fit? Well, now that you are seasoned VB.Net programmers with Multiform Project knowledge and experience, you now possess the tools to rectify that situation, and choose the best name for your little munchkin. Let's see how to do just that. Create a new project in Visual Studio. Change the following properties on the default form:

    1. Name: MainForm
    2. Text: Main Form

    As indicated in the diagram below:

    Form Properties

    Figure MFP-3: Visual Basic Multiform Project Main Form Properties

    Help Support this site - Click this ad

    From the Common Controls section of the Visual Studio ToolBox. Add the following controls and make the necessary changes to each of the control's properties as indicated below:

    1. Common Controls:
    2. Button:
      • Name: btnChangeName
      • Text: Change Name
    3. Label:
      • Name: lblPetName
      • Text: Name: Howie
    4. Picture Box:
      • Name: MyDogPicture

    And as indicated in the diagram below:

    Form 1 Controls

    Figure MFP-4: Visual Basic Multiform Project Main Form Controls

    In order to continue with this guide, and finish this suspenseful, action packed drama of Multiform Project Examples... Press the Button below:

    Help Support this site - Click this ad


    Visual Basic

    Introduction to VB.NET

    .NET Framework

    VS2008 IDE

    How VB is Compiled

    Start Visual Studio

    Windows Form App

    Save Your Work

    VB OOP Programming

    Visual Basic Code

    Exit Code

    Button Event Code

    Coding Recommendations


    Error List Window

    Comment Syntax

    Help Window

    Language Essentianl

    Built-In Data Types

    Declare Variables

    Declare Constants

    Code Arithmetic Expressions

    Assignment Statements

    Operator Precedence

    Type Casting

    Math Class

    String Declaration

    Conversion Functions

    Conversion Methods

    Formatting Functions

    String Formatting

    Variable Scope


    Nullable Types

    Loop Constructs

    For Next Loop

    Do While Loop

    Do Until Loop



    Exit Do | Exit For


    Nested Loops


    Array Declaration

    Rnd( ) Function

    Listbox Control


    Parallel Arrays

    Key Event Args

    Dynamic Arrays

    Redimension Array

    Set Breakpoint

    Start Debugger

    ReDim Preserve

    MultiDimensional Arrays

    DataGridView Control

    Length and Sort Methods


    Pad Right

    Split Method

    IsNumeric Function

    Multiform Projects

    Add Form To Project

    Form Object Methods

    Form Show Method

    ShowDialog Method

    Form Close Method

    Form Accept Button

    Multiform Project Example

    ASP.NET Web Programming

    Create Data Source

    Configure Access Data Source

    Add Product Class

    Extract Local Database Data

    Order PageLoad VB Code

    Add New Web Page

    Set Start Page

    Display Cart Aspx Code

    Display Cart Design View

    Sorted List Definition

    VB.NET Session State

    Create CartItem Class

    GetCartContents Function

    Add To Cart Event Handler

    Remove Cart Item Event

    Clear Cart Event Handler