© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 1 Unit 1 Introduction to Programming Using VB.NET Chapter.

Slides:



Advertisements
Similar presentations
Creating Applications With Visual Basic
Advertisements

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 2- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
© by Pearson Education, Inc. All Rights Reserved. continued …
Chapter 2 –Visual Basic, Controls, and Events
 2006 Pearson Education, Inc. All rights reserved Introduction to the Visual C# 2005 Express Edition IDE.
Compunet Corporation Programming with Visual Studio.NET GUI Week 13 Tariq Aziz and Kevin Jones.
Chapter Creating Applications With Visual Basic 2.
Chapter Creating Applications With Visual Basic 2.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Copyright © 2014 Pearson Education, Inc. Chapter 2 Creating Applications with Visual Basic.
110-C1 Chapter 2 of the text: _ text boxes, group boxes, check boxes, radio buttons, picture boxes _ defining access keys tab sequence setting the focus.
Chapter 2 –Visual Basic, Controls, and Events
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
Visual Basic Chapter 1 Mr. Wangler.
05/09/ Introducing Visual Basic Sequence Programming.
Chapter 1 P. 1 Writing Windows applications with Visual Basic Figure 1.1 The first program works as follows: (These operations can be performed in any.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
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 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
CSCI Chapter 2 Creating Application with Visual Basic Instructor: Bindra Shrestha University of Houston – Clear Lake.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Starting Out with Visual Basic.NET 2 nd Edition Chapter 2 Creating Applications With Visual Basic.NET.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Copyright © 2014 Pearson Education, Inc. Chapter 2 Creating Applications with Visual Basic.
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.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Chapter 2 –Visual Basic, Controls, and Events
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 Designing Applications Programming with Microsoft Visual Basic th Edition.
Visual Basic.NET BASICS Lesson 3 Events and Code.
 2006 Pearson Education, Inc. All rights reserved Introduction to the Visual C# 2005 Express Edition IDE.
Chapter 2 - VB 2008 by Schneider1 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual.
OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
 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 2005 BASICS Lesson 3 Events and Code.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 4 Designing the Inventory Application Introducing TextBox es and Button s.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
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.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
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.
Chapter 2 - VB 2008 by Schneider1 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
 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.
Chapter 2 – Introduction to the Visual Studio .NET IDE
3.01 Apply Controls Associated With Visual Studio Form
3.01 Apply Controls Associated With Visual Studio Form
Visual studio 2010 SENG 403, Tutorial 2 SENG Winter 2011.
Introduction to the Visual C# 2005 Express Edition IDE
Creating Applications with Visual Basic
Chapter 2 – Introduction to the Visual Studio .NET IDE
Building an Application in the Visual Basic .NET Environment
STARTING OUT WITH Visual Basic 2008
GUI Programming in Visual Studio .NET
Presentation transcript:

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 1 Unit 1 Introduction to Programming Using VB.NET Chapter 2 Creating Applications with VB.NET

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 2 A First Visual Basic.NET Application Develop your first application:  Display a map and written directions to the Highlander Hotel  Use a form with labels  Use a PictureBox control  Write an event procedure

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 3 Focus on Problem Solving: Building the Hotel Directions Application In This Section You Create Your First Visual Basic.NET Application: a Window That Displays a Map and Road Directions to a Hotel

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 4 Clearly Define What the Program is To Do Purpose: Display a map to the Highlander Hotel Input: None Process: Display a form Output: Display a graphic image showing a map on the form

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 5 Visualize the Application Running on the Computer and Design its User Interface

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 6 Make a List of the Controls Needed Control TypeDescription (Control Name) FormA small form that will serve as (Default Name: Form1)the window onto which the other controls will be placed LabelDisplays the message (Default Name: Label1) "Directions to the Highlander Hotel" PictureBoxDisplays the graphic image (Default Name: PictureBox1)showing the map to the hotel

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 7 Define the Values of Each Control's Relevant Properties Form  Name: Form1  Text: "Directions" Label  Name: Label1  Text: "Directions to the Highlander Hotel"  TextAlign: MiddleCenter  Font: Microsoft sans serif, bold, 18 point PictureBox  Name: PictureBox1  Picture: HotelMap.jpg  SizeMode: StretchImage

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 8 Use Visual Basic.NET to Create the Forms and Other Controls Establish the Form Add the Labels Set the TextAlign Property, Font and Style Insert a PictureBox Control Try Running the Application

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 9 Project Organization on Disk Each Solution is stored as a Visual Basic.NET Project Within the Folder created with the project name are various files, including: .sln contains data describing the solution .vbproj contains data describing the project

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 10 Properties Window Used to view and modify the property values of a given object Two views of the properties:  Alphabetic (across all properties)  Categorized (groups properties by logical use)

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 11 Focus on Problem Solving: Responding to Events An Application Responds to Events, Such As Mouse Clicks and Keyboard Input, by Executing Code Known As Event Procedures In This Section, You Write Event Procedures for the Directions Application

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 12 Augment the Hotel Application Now the hotel owner wants to add an option to view written directions:

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 13 Controls to be Added Control TypeDescription (Control Name) LabelDisplays written directions to (lblDirections)the hotel ButtonWhen clicked, causes the above (btnDisplayDirections) label to appear on the form ButtonStops the application (btnExit)when clicked

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 14 Direction's Application Control Properties Label:  Name: lblDirections  Text: "Traveling …" Button  Name: btnDisplayDirections  Text: "Display Directions" Button:  Name: btnExit  Text: "Exit"

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 15 Method btnDisplayDirections_Click, I Private Sub btnDisplayDirections_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnDisplayDirections.Click ' Make the directions visible lblDirections.Visible = True End Sub Line Continuation Mark Name of the event the procedure responds to Name of the control that owns the event procedure Marks the beginning of this event procedure

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 16 Method btnDisplayDirections_Click, II Private Sub btnDisplayDirections_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnDisplayDirections.Click ' Make the directions visible lblDirections.Visible = True End Sub Makes the control lblDirections visible: Assigns the value True to the Visible Property of the lblDirections control.

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 17 Syntax for Referring to the Value of a Control's Property ControlName Dot PropertyName In this situation:  lblDirections.Visible

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 18 Syntax for an Assignment Statement Item receiving the value Equal symbol Value to be assigned In this situation:  lblDirections.Visible = True

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 19 Use Visual Basic.NET to Update the Application Place the label and the buttons on the form Enter the code for the two procedures Test the application

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 20 Additional Properties Color properties:  BackColor: Sets the background color  ForeColor: Sets the foreground (e.g., text) color Form style property value examples:  Sizable: (Default) Has normal buttons in upper right and is resizable via the edges  Fixed3D: Has a 3D look; normal buttons; is not resizable by its edges

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 21 Modifying the Text Property With Code Quite Often, You Will Need to Change a Control’s Text Property With Code This Is Done With an Assignment Statement

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 22 The Text Property Can Be Modified via Code, I Suppose that a form was established with a label lblMessage that said: 1 Kilometer = ? And on a btnfeet button click, we wanted to change the value of the text property to 1 Kilometer = 3,281 feet

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 23 The Text Property Can Be Modified via Code, II Private Sub btnFeet_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnFeet.Click ' Display the conversion to feet. lblMessage.Text = "1 Kilometer = 3,281 feet" End Sub Assigns the given string to the text property of lblMessage This has the effect of changing the previously displayed value to this one

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 24 The AutoSize, BorderStyle, and TextAlign Properties The Label Control’s AutoSize Property Allows a Label to Change Size Automatically to Accommodate the Amount of Text in Its Text Property The BorderStyle Property Allows You to Set a Border Around a Label Control

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 25 AutoSize Property for Labels AutoSize is a Boolean (True or False) Property of labels False (the default) means that the box size will not change, depending on the amount of text assigned to it True means that it will resize itself to fit variable amounts of text

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 26 BorderStyle Property for Labels BorderStyle determines the look of the box  None (the default) means no border  FixedSingle means a border one pixel wide  Fixed3D gives it a recessed 3-dimensional look

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 27 TextAlign Property for Labels The value of TextAlign establishes the text's justification:  TopLeft  TopCenter  TopRight  MiddleLeft  MiddleCenter –MiddleRight –BottomLeft –BottomCenter –BottomRight

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 28 Clickable Images Controls Other Than Buttons Have Click Event Procedures

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 29 PictureBox Control As we saw earlier the Image Property can be set to an graphic of some sort The image is clickable This event can be handled by code to take whatever the appropriate action is

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 30 PictureBox Click Event code When PictureBox picUSA is clicked, lblMessage is set appropriately: Private Sub picUSA_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles picUSA.Click ' Display the country name lblMessage.Text = "United States of America" End Sub

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 31 Using Visual Basic.NET Help In This Section You Learn to Use the Visual Basic.NET Help System

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 32 Dynamic Help Dynamic Help provides help information that is relevant to the operation you are currently performing This window occupies the same location as the Properties window Simply select the tab at the bottom to select which you wish to view

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 33 Help Menu The usual categories of Help that you are probably accustomed to in Microsoft applications  Contents…  Index…  Search… Are available through this window also

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 34 Debugging Your Application At Some Point, Most Applications Contain Bugs, or Errors That Prevent the Application From Operating Properly

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 35 Types of Errors: Compile Errors These are errors in the syntax (form) of your program Visual Basic.NET will inform you of these as soon as they are found The area of the error will be shown with a jagged blue line A description of the error will be given in the Task List window

© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 36 Types of Errors: Runtime Errors These errors occur while your program is running Visual Basic.NET will detect some of these and inform you about them Others you must detect yourself Always carefully check the operation of your program to be sure that it operates as required