|
Hot-Link Menu in Right-Side Column |
Last Updated 6-30-2010 |
||||||||||||||||||||||||||||||||||||||||||||
|
Multiform ProjectsIt 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:
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 MethodsThe 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:
This is all of the code associated with our Form object before we have added any controls, events or procedures to the form:
Visual Basic Show( ) MethodThe 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( )
Visual Basic ShowDialog( ) MethodThe 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( ) MethodThe 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( ) MethodThe 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
Visual Basic Multiform Project ExampleHave 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:
As indicated in the diagram below:
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:
And as indicated in the diagram below:
In order to continue with this guide, and finish this suspenseful, action packed drama of Multiform Project Examples... Press the Button below:
|
Home 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 ProgrammingVisual Basic Code Exit Code Button Event Code Coding RecommendationsIf/Then/Else Error List Window Comment Syntax Help Window Language Essentianl Built-In Data Types Declare Variables Declare ConstantsCode Arithmetic Expressions Assignment Statements Operator Precedence Type Casting Math Class String DeclarationConversion Functions Conversion Methods Formatting Functions String Formatting Variable Scope EnumerationsNullable Types Loop Constructs For Next LoopDo While Loop Do Until Loop Do...Loop-WhileDo...Loop-Until Exit Do | Exit For Do...LoopNested Loops Arrays Array DeclarationRnd( ) Function Listbox ControlKeyPressEventArgs Parallel Arrays Key Event ArgsDynamic Arrays Redimension ArraySet Breakpoint Start Debugger ReDim Preserve MultiDimensional Arrays DataGridView ControlLength and Sort Methods Structures Pad RightSplit 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 SourceConfigure Access Data Source Add Product Class Extract Local Database Data Order PageLoad VB CodeAdd New Web Page Set Start Page Display Cart Aspx CodeDisplay Cart Design View Sorted List Definition VB.NET Session State Create CartItem Class GetCartContents FunctionAdd To Cart Event Handler Remove Cart Item EventClear Cart Event Handler |