Chapter 1: An Introduction to Visual Basic .NET

Slides:



Advertisements
Similar presentations
Chapter 1: An Introduction to Visual Basic 2012
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
© by Pearson Education, Inc. All Rights Reserved.
 2006 Pearson Education, Inc. All rights reserved Introduction to the Visual C# 2005 Express Edition IDE.
Chapter 1: An Introduction to Visual Basic.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Microsoft Visual Basic 2010: Reloaded Fourth Edition
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Visual Basic Chapter 1 Mr. Wangler.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2005: Reloaded Second Edition
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
IE 411/511: Visual Programming for Industrial Applications
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET.
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
Teacher: Ms. Olifer MICROSOFT VISUAL STUDIO 2010: PROPERTIES OF WINDOWS FORM OBJECT.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 2 Creating a User Interface.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Visual Basic.NET BASICS Lesson 1 A First Look at Microsoft Visual Basic.NET.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Microsoft Visual Basic 2005 BASICS Lesson 1 A First Look at Microsoft Visual Basic.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Chapter 3 I Need a Tour Guide (Introduction to Visual Basic 2010) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
 You won’t write a single line of program code.  Instead, you’ll use visual programming techniques.  Visual Studio processes your actions (such as mouse.
Programming with Microsoft Visual Basic 2012 Chapter 1: An Introduction to Visual Basic 2012.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter One An Introduction to Visual Basic 2008.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Dive Into® Visual Basic 2010 Express
Chapter 3: I Need a Tour Guide (Introduction to Visual Basic 2012)
Excel Tutorial 8 Developing an Excel Application
Visual Basic.NET Windows Programming
Microsoft Visual Basic 2005: Reloaded Second Edition
Chapter 2: The Visual Studio .NET Development Environment
Chapter 1: An Introduction to Visual Basic 2012
Chapter 1: An Introduction to Visual Basic 2015
Chapter 2 – Introduction to the Visual Studio .NET IDE
3.01 Apply Controls Associated With Visual Studio Form
Programming with Microsoft Visual Basic th Edition
Program and Graphical User Interface Design
3.01 Apply Controls Associated With Visual Studio Form
Chapter 1: An Introduction to Visual Basic 2015
Introduction to the Visual C# 2005 Express Edition IDE
Using Procedures and Exception Handling
Chapter 2 Visual Basic Interface
Program and Graphical User Interface Design
Chapter 2 – Introduction to the Visual Studio .NET IDE
CIS16 Application Development Programming with Visual Basic
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Presentation transcript:

Chapter 1: An Introduction to Visual Basic .NET Programming with Microsoft Visual Basic .NET, Second Edition

Creating a Windows-Based Application in Visual Basic Creating a Windows-Based Application in Visual Basic .NET Lesson A Objectives Start and customize Visual Studio.NET Create a Visual Studio .NET solution Add a Visual Basic .NET project to a solution Set the properties of an object Restore a property to its default setting Programming with Microsoft Visual Basic .NET, Second Edition

Creating a Windows-Based Application in Visual Basic Creating a Windows-Based Application in Visual Basic .NET Lesson A Objectives (continued) Save a solution, project, and form Close a solution Open an existing solution Programming with Microsoft Visual Basic .NET, Second Edition

Starting and Customizing Visual Studio .NET Visual Studio .NET is Microsoft’s newest integrated development environment (IDE) Includes programming languages such as Visual Basic .NET, C++ .NET, and C# .NET A Windows-based application has a Windows user interface and runs on a desktop computer A user interface is what you see and interact with when using an application A Web-based application has a Web user interface and runs on a server Programming with Microsoft Visual Basic .NET, Second Edition

Starting and Customizing Visual Studio .NET (continued) Windows in the Visual Studio .NET IDE: Start Page Solution Explorer Server Explorer Toolbox Class View Dynamic Help Programming with Microsoft Visual Basic .NET, Second Edition

Starting and Customizing Visual Studio .NET (continued) Figure 1-3: Projects pane in the Start Page window Programming with Microsoft Visual Basic .NET, Second Edition

Creating the Copyright Screen Application Applications created in Visual Studio .NET are composed of solutions, projects, and files A solution is a container that stores the projects and files for an entire application A project is a container that stores files associated with only a specific piece of the solution To create an application: Create a blank Visual Studio .NET solution Add one or more projects to the solution Programming with Microsoft Visual Basic .NET, Second Edition

Creating the Copyright Screen Application (continued) Figure 1-6: New Project dialog box used to create a blank solution Programming with Microsoft Visual Basic .NET, Second Edition

Creating the Copyright Screen Application (continued) Figure 1-9: New Visual Basic .NET project added to the solution Programming with Microsoft Visual Basic .NET, Second Edition

The Windows Form Designer Window Windows Form Designer window is where you create (or design) the graphical user interface (GUI) for your project You create the user interface by adding other objects (such as buttons and text boxes) to a Windows Form object (or form) Programming with Microsoft Visual Basic .NET, Second Edition

The Windows Form Designer Window (continued) Figure 1-11: Windows Form Designer window Programming with Microsoft Visual Basic .NET, Second Edition

The Solution Explorer Window The Solution Explorer window displays: A list of projects contained in the current solution Items contained in each project The Solution Explorer window shows that the Copyright Solution contains one project named Copyright Project Within the Copyright Project is: A References folder Two files: AssemblyInfo.vb and Form1.vb Programming with Microsoft Visual Basic .NET, Second Edition

The Solution Explorer Window (continued) Figure 1-12: Solution Explorer window Programming with Microsoft Visual Basic .NET, Second Edition

The Properties Window Each object has a set of attributes, called properties, that determine its appearance and behavior The Properties window exposes the object’s properties to the programmer The Properties window includes an Object box and a Properties list The Properties window can be used to change a property of an object Programming with Microsoft Visual Basic .NET, Second Edition

The Properties Window (continued) Figure 1-15: Properties window showing the properties of the Form1.vb file object Programming with Microsoft Visual Basic .NET, Second Edition

Properties of the Windows Form Object The Windows Form object has a set of properties Properties of the Windows Form object will appear in the Properties window when you select the Windows Form object in the designer window Programming with Microsoft Visual Basic .NET, Second Edition

Properties of the Windows Form Object (continued) Important properties of the Windows Form object: Name property Text property StartPosition property Size property BackgroundImage property Programming with Microsoft Visual Basic .NET, Second Edition

Saving a Solution Options for saving a solution: Click File on the menu bar, and then click Save All Click the Save All button on the Standard toolbar Select the solution’s name in the Solution Explorer window, and then click the Save button on the Standard toolbar Programming with Microsoft Visual Basic .NET, Second Edition

Closing the Current Solution You close a solution using the Close Solution option on the File menu When you close a solution, all projects and files contained in the solution also are closed If unsaved changes were made to the solution, project, or form, a dialog box opens and prompts you to save the appropriate files Programming with Microsoft Visual Basic .NET, Second Edition

Opening an Existing Solution To open an existing solution: Click File on the menu bar and then click Open Solution Select the appropriate solution file in the Open Solution dialog box Only one solution can be open in the IDE at any one time Programming with Microsoft Visual Basic .NET, Second Edition

Exiting Visual Studio .NET You exit an application using either: The Close button on the application window’s title bar The Exit option on the File menu Programming with Microsoft Visual Basic .NET, Second Edition

Working with Controls Lesson B Objectives Add a control to a form Set the properties of a label, picture box, and button control Select multiple controls Center controls on the form Set the properties of a project Programming with Microsoft Visual Basic .NET, Second Edition

Working with Controls Lesson B Objectives (continued) Start and end an application Enter code in the Code Editor window Terminate an application using the Me.Close method Programming with Microsoft Visual Basic .NET, Second Edition

The Toolbox Window The Toolbox window, or toolbox, contains the tools and other components you use when designing a user interface The contents of the toolbox vary depending on the designer in use Tools in the toolbox allow you to create objects, called controls, that can be displayed on a form Programming with Microsoft Visual Basic .NET, Second Edition

The Toolbox Window (continued) The Windows Form tab Contains the tools you use when designing your user interface Contains 47 basic tools You can add new tools or delete existing tools By default, the tools on the Windows Form tab are listed in order by their estimated frequency of use, with the most used tools listed first Programming with Microsoft Visual Basic .NET, Second Edition

Using the Label Tool You use the Label tool to create a label control The purpose of a label control is to display text that the user is not allowed to edit while the application is running Assigning meaningful names to the controls on a form will help you keep track of the various controls in the user interface Programming with Microsoft Visual Basic .NET, Second Edition

Using the Label Tool (continued) Used to display data that users cannot change Property Description Name Identifies the object in code Text Displays information AutoSize Determines if the object resizes itself to display all Text Location Sets the X and Y coordinates for where label is displayed Font Characteristics of the displayed Text Programming with Microsoft Visual Basic .NET, Second Edition

Changing the Property for More Than One Control at a Time You can use the Font property to change the appearance of many of the objects in your user interface The Font property allows you to change the type, style, and size of the font used to display the text in the object A font is the general shape of the characters in the text Programming with Microsoft Visual Basic .NET, Second Edition

Changing the Property for More Than One Control at a Time (continued) Font sizes are typically measured in points, with one point equaling 1/72 of an inch One reason for changing a font is to bring attention to a specific part of the screen You can change the font size for both controls at the same time by clicking one control and then pressing and holding down the Control key as you click the other control in the form Programming with Microsoft Visual Basic .NET, Second Edition

Changing the Property for More Than One Control at a Time (continued) You can use the Control+Click method to select as many controls as you want To cancel the selection of one of the selected controls, press and hold down the Control key as you click the control To cancel the selection of all of the selected controls, release the Control key, then click the form or an unselected control on the form Programming with Microsoft Visual Basic .NET, Second Edition

Using the Format Menu Align option aligns two or more controls by their left, right, top, or bottom borders Make Same Size option makes two or more controls the same width and/or height Center in Form option centers one or more controls either horizontally or vertically on the form Programming with Microsoft Visual Basic .NET, Second Edition

Using the PictureBox Tool You can include a logo by displaying the logo in a picture box control, which you create using the PictureBox tool Programming with Microsoft Visual Basic .NET, Second Edition

Using the Button Tool Every Windows application should give the user a way to exit the program Most Windows applications provide either an Exit option on a File menu or an Exit button for this purpose In Windows applications, a button control performs an immediate action when clicked You create a button using the Button tool in the toolbox Programming with Microsoft Visual Basic .NET, Second Edition

Starting and Ending an Application You can start an application by: Clicking Debug on the menu bar, and then clicking Start Or, pressing the F5 key on your keyboard Programming with Microsoft Visual Basic .NET, Second Edition

Starting and Ending an Application (continued) You can stop the copyright screen application by: Clicking the Close button on the form’s title bar Or, clicking the designer window to make it the active window, then clicking Debug on the menu bar, and then clicking Stop Debugging Or, pressing Shift+F5 Programming with Microsoft Visual Basic .NET, Second Edition

Writing Visual Basic .NET Code Users actions—such as clicking, double-clicking, and scrolling—are called events The set of Visual Basic .NET code that tells an object how to respond to an event is called an event procedure A class definition is a block of code that specifies (or defines) the attributes and behaviors of an object Programming with Microsoft Visual Basic .NET, Second Edition

Writing Visual Basic .NET Code (continued) The Class Name list box lists the names of the objects included in the user interface The Method Name list box lists the events to which the selected object is capable of responding Code Editor provides you with a code template for every event procedure First line in the Code template is the procedure header Programming with Microsoft Visual Basic .NET, Second Edition

Writing Visual Basic .NET Code (continued) Last line in the Code template is the procedure footer A keyword is a word that has a special meaning in a programming language The Sub keyword refers to a block of code that performs a specific task The Private keyword indicates that the procedure can be used only within the class in which it is defined Programming with Microsoft Visual Basic .NET, Second Edition

Writing Visual Basic .NET Code (continued) Parameters represent information that is passed to the procedure when it is invoked A method is a predefined Visual Basic .NET procedure that you can call (or invoke) when needed When you call the Me.Close method, Visual Basic .NET terminates the current application Programming with Microsoft Visual Basic .NET, Second Edition

Writing Visual Basic .NET Code (continued) Private Sub uiExitButton_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles uiExitButton.Click Private Sub Indicates the start of a code unit that can only be used in this class uiExitButton_Click The name of the procedures is the object name and event name connected with an underscore sender As Object Identifies the object creating the event e As System.EventArgs Identifies specific information about the event Handles Identifies the object and event that this procedure will handle The uiExitButton’s Click event procedure Programming with Microsoft Visual Basic .NET, Second Edition

Writing Visual Basic .NET Code (continued) Private Sub uiExitButton_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles uiExitButton.Click Me.Close() End Sub The event procedure Programming with Microsoft Visual Basic .NET, Second Edition

Completing the Copyright Screen Lesson C Objectives Set the properties of a timer control Delete a control from the form Delete code from the Code Editor window Code the timer control’s Tick event Remove and/or disable the Minimize, Maximize, and Close buttons Prevent the user from sizing a form Print the project’s code Programming with Microsoft Visual Basic .NET, Second Edition

Using the Timer Tool Splash screens typically use a timer control to automatically remove the splash screen after a set period of time You create a timer control using the Timer tool in the toolbox You can use a timer control to process code at regular time intervals You set the timer control’s Interval property to the length of the desired time interval, in milliseconds Programming with Microsoft Visual Basic .NET, Second Edition

Using the Timer Tool (continued) You also set its Enabled property to True The Enabled property determines whether an object can respond to an event You then enter the code you want processed into the control’s Tick event procedure The Tick event procedure tells the computer what to do after each time interval has elapsed Programming with Microsoft Visual Basic .NET, Second Edition

Using the Timer Tool (continued) Figure 1-35: Timer control placed in the component tray Programming with Microsoft Visual Basic .NET, Second Edition

Setting the FormBorderStyle Property The FormBorderStyle property determines the border style of a Windows Form object FromBorderStyle setting Description Fixed3D Fixed, three-dimensional FixedDialog Fixed, thick dialog-style FixedSingle Fixed, thin line FixedToolWindow Fixed, tool window style None No border Sizable Sizable, normal style (default) SizableToolWindow Sizable, tool window style Programming with Microsoft Visual Basic .NET, Second Edition

The MinimizeBox, MaximizeBox, and ControlBox Properties You can use a Windows Form object’s MinimizeBox property to disable the Minimize button You can use the MaximizeBox property to disable the Maximize button Splash screens typically do not contain a title bar You can remove the title bar by setting the Windows Forms object’s ControlBox property to False, and then removing the text from its Text property Programming with Microsoft Visual Basic .NET, Second Edition

Printing Your Code You always should print a copy of the code entered in the Code Editor window, because the printout will help you understand and maintain the application in the future To print the code, the Code editor window must be the active, or current, window Programming with Microsoft Visual Basic .NET, Second Edition

Summary To create a blank solution, click File on the menu bar, point to New, and then click Blank Solution You can add a new project to the current solution by clicking File on the menu bar, pointing to Add Project, and then clicking New Project To save a solution, click File on the menu bar, and then click Save All To open an existing solution, click File on the menu bar, and then click Open Solution Programming with Microsoft Visual Basic .NET, Second Edition

Summary (continued) To add a control to a form, click the appropriate tool in the toolbox, but do not release the mouse button, drag the mouse pointer to the form, and release the mouse button To select multiple controls, click one control, then Control+click each of the other controls One way to open the Code Editor window is to right-click anywhere on the form (except the form’s title bar), and then click View Code on the context menu Programming with Microsoft Visual Basic .NET, Second Edition

Summary (continued) Use the Timer tool to perform code at specified intervals of time Set the form’s FormBorderStyle property to control the border style of the form To print the Visual Basic .NET code, open the Code Editor window, click File on the menu bar, click Print, and then click the OK button in the Print dialog box Programming with Microsoft Visual Basic .NET, Second Edition