Chapter 1: An Introduction to Visual Basic 2015

Slides:



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

© 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.
Using the Visual Basic Editor Visual Basic for Applications 1.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
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)
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
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
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
IE 411/511: Visual Programming for Industrial Applications
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Chapter 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
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.
 2009 Pearson Education, Inc. All rights reserved Introduction to the Visual Basic Express 2008 IDE.
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.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
Chapter Two Creating a First Project in Visual Basic.
Chapter 2 – Introduction to the Visual Studio .NET IDE
1.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
Chapter 3 I Need a Tour Guide (Introduction to Visual Basic 2010) Clearly Visual Basic: Programming with Visual Basic nd Edition.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
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.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
 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.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
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.
Dive Into® Visual Basic 2010 Express
Chapter 3: I Need a Tour Guide (Introduction to Visual Basic 2012)
Chapter 1: An Introduction to Visual Basic .NET
Visual Basic.NET Windows Programming
Chapter 2: The Visual Studio .NET Development Environment
Chapter 1: An Introduction to Visual Basic 2012
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
1. Introduction to Visual Basic
3.01 Apply Controls Associated With Visual Studio Form
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
MODULE 7 Microsoft Access 2010
Chapter 2 – Introduction to the Visual Studio .NET IDE
CIS16 Application Development Programming with Visual Basic
Programming with Microsoft Visual Basic 2008 Fourth Edition
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 2015

Lesson B Objectives After studying Lesson B, you should be able to: Add a control to a form Set the properties of a label, picture box, and button control Select multiple controls Change the layering order of controls Center controls on the form Open the Project Designer window Start and end an application Enter code in the Code Editor window Terminate an application using the Me.Close() instruction Run the project’s executable file Programming with Microsoft Visual Basic 2015

Wndows In lesson 1A you have learned about: Windows Form Designer Solution Explorer Window Properties Window In this lesson you will learn about the Toolbox window (also known as toolbox) The toolbox contains the tools you will use to create your application’s user interface Each tool represents a class from which an object such as a button or textbox can be instantiated Instantiated objects called controls will appear on the form Programming with Microsoft Visual Basic 2015

The Toolbox Window Class Object Toolbox window (or toolbox) Controls A pattern from which an object is created Object An instance with behaviors and attributes Toolbox window (or toolbox) Contains tools for designing a user interface Each tool represents a class Controls are instantiated using tools from the toolbox Controls GUI objects that appear on a form Programming with Microsoft Visual Basic 2015

The Toolbox Window (cont.) Figure 1-13 Toolbox window showing the purpose of the Label tool Programming with Microsoft Visual Basic 2015

The Label Tool (p29) Use the Label tool to add a label control to a form A label control displays text that cannot be edited at run time (it means that the user is not allowed to modify) Notice that Appears in the Object box in the properties window Label1 is the Label1 is the default name assigned to the label control System.Windows.Forms.Label indicates that the control is an instance of the Label class Programming with Microsoft Visual Basic 2015

The Label Tool (p29) Name property (p30) Text property (p31) A unique name for a control Text property (p31) Specifies the value that appears in a label control Location property (p31) Specifies the location of a control on a form Includes an X value and a Y value How do you select a control on the form without clicking on it? Your answer is: ? Programming with Microsoft Visual Basic 2015

Figure 1-15 Label control added to the form The Label Tool (cont.) Figure 1-15 Label control added to the form Programming with Microsoft Visual Basic 2015

The Label Tool (cont.) Setting the Text Property Select the lblMsg control Click text in the Properties list Type Come visit our residents! Press Enter Verify that the AutoSize property is set to True Select the lblName control Type Crighton Zoo Programming with Microsoft Visual Basic 2015

The Label Tool (cont.) Setting the Location Property Select the lblMsg control Click Location in the Properties list Expand the Location property by clicking the plus box Type 180, 115 Press Enter Select the lblName control Type 180, 70 Programming with Microsoft Visual Basic 2015

Changing a Property For Multiple Controls (p31) A control inherits the font attribute of the form Sometimes You may want to use different font type, style, or size for a control text You can change the font, the size o other property of one control (or more than one control of the same class) In the Splash screen You can make the text in the two label controls more noticeable by increasing the size of the font used to display text (p31) Select the first control, hold down the Ctrl (Control) key as you select the other control (or controls) on the form Figure 1-16 Label controls selected on the form Programming with Microsoft Visual Basic 2015

Changing a Property For Multiple Controls (p31) A control inherits the font attribute of the form Sometimes You may want to change the default values To simultaneously modify similar controls: Click one control and then press and hold the Ctrl key Click other similar control(s) in the form, or click and drag to group the controls Set the property value in the Properties list Figure 1-16 Label controls selected on the form Programming with Microsoft Visual Basic 2015

Changing a Property For Multiple Controls (cont.) Using the Format Window’s Order Option (p32) The Format menu contains an Order option that allows you to control the layering of one or more controls on a form Using the Format Menu’s Order Option (p32) Change the form’s Backcolor property to dark green Add… 3… Figure 1-17 New label on top of previous labels Programming with Microsoft Visual Basic 2015

Changing a Property For Multiple Controls (cont.) Using the Format Window’s Order Option (p32) To layer one control over another layer Create a label control and size it to cover other labels Figure 1-17 New label on top of previous labels Programming with Microsoft Visual Basic 2015

Changing a Property For Multiple Controls (cont.) Using the Format Window’s Order Option (p33) To reverse the layers Click the label control on the form Click Format on the menu bar Point to Order and then click Send to Back Figure 1-17 New label on top of previous labels Programming with Microsoft Visual Basic 2015

The PictureBox Tool (p33) You can include an image on a form using a picture box control which you instantiate using the picture box control Programming with Microsoft Visual Basic 2015

The PictureBox Tool (p33) Creates a picture box control Displays an image on a form Task box: Lists tasks associated with a picture box Use the task box to import an image into a project A project’s resource file contains imported images Figure 1-19 Open task list for a picture box Figure 1-20 Completed Select Resource dialog box Programming with Microsoft Visual Basic 2015

The PictureBox Tool (cont.) Figure 1-21 Picture boxes added to the form Programming with Microsoft Visual Basic 2015

The PictureBox Tool (cont.) Using the Format Menu to Align and Size (p35) The Format menu provides a Center in Form options for centering one or more controls either vertically or horizontally on the form The Format menu also provides an align option for aligning two or more controls by their left, right, top, or bottom borders The menu Make Same Size option allows to make to or more two or more controls the same width and/or height Before you can use the Format menu to change the alignment or size of two or more controls, you must first select the controls Programming with Microsoft Visual Basic 2015

The PictureBox Tool (cont.) Select the reference control first . The reference control is the one whose size and/or location you want to match The reference control will have white sizing handles, Whereas the other selected controls will have black sizing handles Programming with Microsoft Visual Basic 2015

The Button Tool (p36) Every application should give the user a way to exit a program Most Windows applications accomplish the task by using either an exit option on the File menu or an exit button In this lesson the splash screen will provide a button for ending the application In Windows applications a button control is commonly used to perform an immediate action when clicked The OK and Cancel button are examples of button controls found in many Windows applications. Programming with Microsoft Visual Basic 2015

The Button Tool Used to create a button control Used to perform an action when clicked Examples: OK and Cancel buttons Common means of exiting a Windows application: Exit option on the FILE menu Exit button Programming with Microsoft Visual Basic 2015

The Button Tool Steps to add a Button control to the form (p36) Use the button tool in the toolbox The three-character ID used when naming button control is btn Programming with Microsoft Visual Basic 2015

Starting and Ending an Application Startup form Displays when an application is first started The Project Designer window specifies the startup form or the executable code to be run Right-click My Project in the Solution Explorer window and then click Open Or, click PROJECT on the menu bar and then click <project name> Properties Application tab Specify startup form Programming with Microsoft Visual Basic 2015

Programming with Microsoft Visual Basic 2015

Starting and Ending an Application (cont.) Executable file A file that can be run outside of the IDE Its filename ends with .exe It is automatically created when a Visual Basic application is started Two ways to start an application in the IDE: Click DEBUG on the menu bar and then click Start Debugging Press the F5 key Figure 1-22 Application pane in the Project Designer window Programming with Microsoft Visual Basic 2015

The Code Editor Window (p 39) After creating your application interface, you can begin entering the Visual Basic instructions (code) that tells the controls how to respond to the user’s actions Those actions such as clicking, double-clicking, and scrolling are called events You tell an object how to respond to an event by writing an event procedure which is a set of Visual Basic instructions that are processed only when the event occurs. You enter the procedure’s code in the Code Editor window. In this lesson you will write a Click event procedure for the Exit button which should end the application when it is clicked Programming with Microsoft Visual Basic 2015

The Code Editor Window Events Event procedure Code Editor window User actions such as double-clicking Event procedure A set of program instructions that are processed when an event occurs Code Editor window Provides templates for creating event procedures To open it, right-click the form and then click View Code Programming with Microsoft Visual Basic 2015

The Code Editor Window (cont.) Figure 1-24 Code Editor window opened in the IDE Programming with Microsoft Visual Basic 2015

The Code Editor Window (p39) Figure 1-26 was obtained using Visual Studio 2015. lets use this figure to illustrate the paragraph at the bottom of page 39 Project list box Object list box Method list box This Code Editor window contains three (the Visual Studio 2013 provides only two) dropdown list boxes Programming with Microsoft Visual Basic 2015

The Code Editor Window (cont.) Dropdown list boxes named: Project Object Method T he project box contains the name of the current project: Splash Project The object box lists the names of the objects included in the user interface The method box lists the events to which the selected object is capable of responding Programming with Microsoft Visual Basic 2015

The Code Editor Window (cont.) In object-oriented programming (OOP), an event is considered a behavior of an object because it represents an action to which the object can respond In (OOP), the Code Editor window “exposes” an object’s behavior to the programmer You use the Object and Method list boxes to select the object and event, respectively, that you want to code In this case you will select btnExit in the Object list box, and you will select Click in the Method list box This is because you want the application to end when the Exit button is clicked Programming with Microsoft Visual Basic 2015

The Code Editor Window (p 40 cont.) To select the btnExit control’s Click event (p40): 1. Click the object list arrow and then click btnExit in the list Click the Method list arrow and then click and then click Click in the list…. A code template for the btnExit control’s click event procedure appears in the Code Editor window (see Figure 1-26) Figure 1-26 btnExit control’s Click event procedure The code editor provides the code template to help you follow the rules of the Visual Basic language Programming with Microsoft Visual Basic 2015

The Code Editor Window (p 40 cont.) Syntax: The rules of a programming language are called its syntax OOP: Object-oriented programming; events are clickable Procedure header: The first line in the code template for an event procedure Procedure footer: The last line in the code template for an event procedure Keyword: A word that has a special meaning in a programming language Keywords appear in different color than the rest of the code The Private keyword in Figure 1-26 indicates that the button’s Click event procedure can be used only within the current Code Editor window Programming with Microsoft Visual Basic 2015

The Code Editor Window (p 40 cont.) Keyword: A word that has a special meaning in a programming language Keywords appear in different color than the rest of the code The Private keyword in Figure 1-26 indicates that the button’s Click event procedure can be used only within the current Code Editor window The Sub keyword is an abbreviation of the term sub procedure, which is a block of code that performs a specific task Programming with Microsoft Visual Basic 2015

The Code Editor Window (cont.) Sub procedure A block of code that performs a specific task Keywords in a sub procedure block: Sub: Starts a sub procedure Private: Restricts the use of the procedure to the form where it appears End Sub: Indicates the end of a sub procedure Event sub procedure names include the object name and event name Example: btnExit.Click Programming with Microsoft Visual Basic 2015

The Code Editor Window (p 40 cont.) With Visual Studio 2013 you have this Code Editor window Programming with Microsoft Visual Basic 2015

The Code Editor Window (cont.) OOP Object-oriented programming; events are clickable Syntax The rules of a programming language Procedure header The first line in the code template for an event procedure Prcoedure footer The last line in the code template for an event procedure Programming with Microsoft Visual Basic 2015

The Code Editor Window (cont.) The Me.Close() Instruction Method A predefined procedure Can be called (or invoked) when needed Me.Close() method Causes the current form to close If it is the only form in an application, the application terminates IntelliSense feature Provides appropriate selections as pop-up lists Type the first few letters of your choice Then use the arrow keys to select an item in the list Programming with Microsoft Visual Basic 2015

The Code Editor Window (cont.) Figure 1-27 List displayed by the IntelliSense feature Programming with Microsoft Visual Basic 2015

Lesson B Summary To add a control to a form, use a tool from the toolbox Use the label control for text that users cannot edit You can set the properties of multiple controls simultaneously To start and stop an application in the IDE, use DEBUG on the menu bar Use the Code Editor window to display an object’s event procedures The Me.Close() method closes the current form at run time Programming with Microsoft Visual Basic 2015