Microsoft Visual Basic 2005 CHAPTER 5 Mobile Applications Using Decision Structures.

Slides:



Advertisements
Similar presentations
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Working with Large Worksheets, Charting, and What-If Analysis
Microsoft Visual Basic 2008 CHAPTER FIVE Mobile Applications Using Decision Structures.
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.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 4 Reports, Forms, and Combo Boxes.
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2008 CHAPTER FIVE Mobile Applications Using Decision Structures.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Chapter 8: String Manipulation
CHAPTER SIX Loop Structures.
Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services.
CHAPTER 6 Loop Structures.
Microsoft Visual Basic 2012 CHAPTER TWELVE (ENRICHMENT CHAPTER) Windows Store Apps.
CHAPTER SIX.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2008: Reloaded Fourth Edition
Chapter 4: The Selection Structure
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
European Computer Driving Licence Syllabus version 5.0 Module 4 – Spreadsheets Chapter 22 – Functions Pass ECDL5 for Office 2007 Module 4 Spreadsheets.
Chapter 6 Advanced Report Techniques
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 2 Welcome Application Introducing the Visual Basic 2008 Express Edition IDE.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Web Feature Data Access Pages.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 5 Enhancing Forms with OLE Fields, Hyperlinks, and Subforms.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Microsoft Office 2007 Access 2007 Chapter 7 Advanced Report Techniques.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 5 Decision Making.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 5 Enhancing Forms with OLE Fields, Hyperlinks, and Subforms.
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
Dreamweaver CS4 Concepts and Techniques Chapter 2 Adding Web Pages, Links, and Images.
Microsoft Visual Basic 2008 CHAPTER TWELVE Cell Phone Applications and Web Services.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Microsoft Visual Basic 2012 CHAPTER ELEVEN Multiple Classes and Inheritance.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 CHAPTER 5 Mobile Applications Using Decision Structures.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
Microsoft Visual Basic 2012 CHAPTER FIVE Decision Structures.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Microsoft Visual Basic 2010 CHAPTER FOUR Variables and Arithmetic Operations.
Excel Tutorial 8 Developing an Excel Application
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Variables and Arithmetic Operations
Program and Graphical User Interface Design
CHAPTER FIVE Decision Structures.
Using Procedures and Exception Handling
Program and Graphical User Interface Design
CHAPTER FIVE Decision Structures.
Variables and Arithmetic Operations
Presentation transcript:

Microsoft Visual Basic 2005 CHAPTER 5 Mobile Applications Using Decision Structures

5 Chapter 5: Mobile Applications Using Decision Structures2 Objectives ►Write programs for devices other than a personal computer ►Understand the use of handheld technology ►Write handheld applications for a Personal Digital Assistant ►Use the Panel object ►Place RadioButton objects in applications

5 Chapter 5: Mobile Applications Using Decision Structures3 Objectives ►Display a message box ►Make decisions using If…Then statements ►Make decisions using If…Then…Else statements ►Make decisions using nested If statements

5 Chapter 5: Mobile Applications Using Decision Structures4 Objectives ►Make decisions using logical operators ►Make decisions using Case statements ►Insert code snippets ►Test input to ensure a value is numeric

5 Chapter 5: Mobile Applications Using Decision Structures5 Chapter Project

5 Chapter 5: Mobile Applications Using Decision Structures6 Pervasive Devices ►Visual Studio has a built-in emulator that displays a “working” Pocket PC ►Pervasive devices have become important in many business venues

5 Chapter 5: Mobile Applications Using Decision Structures7 Create a Smart Device Application ►With Visual Studio 2005 open, click the New Project button on the Standard toolbar and then, if necessary, click the plus sign next to Smart Device in the Project types pane on the left side of the New Project dialog box ►Click Pocket PC 2003 under Smart Device in the Project types list. In the Templates pane, click Device Application ►Change the Name of the Smart Device application from DeviceApplication1 to WoodCabinetEstimate. Click the OK button

5 Chapter 5: Mobile Applications Using Decision Structures8 Create a Smart Device Application

5 Chapter 5: Mobile Applications Using Decision Structures9 Placing Objects on the PocketPC Form Object ►Many of the same objects used in a Windows application can be placed on the PocketPC Form object ►You cannot resize the Form object ►The PocketPC Form object can be named in the same manner as a Windows Form object using the (Name) property in the Properties window ►Change the Text property of the PocketPC Form object from Form1 to Estimate in the same manner used for the Windows Form object

5 Chapter 5: Mobile Applications Using Decision Structures10 Placing Objects on the PocketPC Form Object

5 Chapter 5: Mobile Applications Using Decision Structures11 Using the Panel Object ►If necessary, open the Device Containers category of the Toolbox by clicking the plus sign next to the category name. Drag the Panel.NET component in the Device Containers category of the Toolbox over the PocketPC Form object to the approximate location where you want to place the Panel object ►When the mouse pointer is in the correct location, release the left mouse button. Increase the size of the Panel object to the approximate size shown in Figure 5-13 by dragging the lower-right sizing handle ►With the Panel object selected, scroll in the Properties window to the (Name) property. Double-click in the right column of the (Name) property and then enter the name pnlWoodType

5 Chapter 5: Mobile Applications Using Decision Structures12 Using the Panel Object

5 Chapter 5: Mobile Applications Using Decision Structures13 Adding the RadioButton Objects ►Drag and drop one RadioButton object from the Toolbox onto the PocketPC Form object inside the Panel object. Drag a second RadioButton object from the Toolbox onto the PocketPC Form object using blue snap lines to align and separate the RadioButton objects vertically ►Release the left mouse button to place the RadioButton object on the PocketPC Form object within the Panel object. Using the same technique, add a third RadioButton object

5 Chapter 5: Mobile Applications Using Decision Structures14 Adding the RadioButton Objects ►Name the RadioButton objects by selecting a RadioButton object, double-clicking in the right column of the (Name) property in the Properties window, and entering the name. The names for the radio buttons, from top to bottom, should be radPine, radOak, and radCherry ►Change the Text property for each RadioButton by double-clicking in the right column of the Text property and typing Pine for the first RadioButton, Oak for the second RadioButton and Cherry for the third RadioButton

5 Chapter 5: Mobile Applications Using Decision Structures15 Adding the RadioButton Objects

5 Chapter 5: Mobile Applications Using Decision Structures16 Windows Application Container Objects

5 Chapter 5: Mobile Applications Using Decision Structures17 Displaying a Message Box

5 Chapter 5: Mobile Applications Using Decision Structures18 Displaying a Message Box

5 Chapter 5: Mobile Applications Using Decision Structures19 Displaying a Message Box

5 Chapter 5: Mobile Applications Using Decision Structures20 Displaying a Message Box

5 Chapter 5: Mobile Applications Using Decision Structures21 Displaying a Message Box

5 Chapter 5: Mobile Applications Using Decision Structures22 Displaying a Message Box

5 Chapter 5: Mobile Applications Using Decision Structures23 Displaying a Message Box ►In the code editing window, inside the event handler you are coding, press CTRL+SPACEBAR. IntelliSense displays the allowable entries. Type mes to select MessageBox in the IntelliSense list ►Type a period (. ) to insert the dot operator. IntelliSense displays a list of the allowable entries. Type s to select Show in the IntelliSense list ►Type the following text: (“You have been disconnected from the Internet”, “ISP”,

5 Chapter 5: Mobile Applications Using Decision Structures24 Displaying a Message Box ►Scroll to the right until there is enough visible room for the remaining entries. Type a space and then select the MessageBoxButtons.RetryCancel argument by pressing the DOWN ARROW key on the keyboard four times ►Type a comma. Then, to select the MessageBoxIcon.Warning argument, press the DOWN ARROW key nine times (or click the argument in the IntelliSense list) ►Type a right parenthesis and then press the ENTER key

5 Chapter 5: Mobile Applications Using Decision Structures25 Displaying a Message Box

5 Chapter 5: Mobile Applications Using Decision Structures26 Displaying a Message Box

5 Chapter 5: Mobile Applications Using Decision Structures27 Making Decisions with Conditional Statements: Using an If…Then Statement ►A decision structure is one of the three fundamental control structures used in computer programming ►When a condition is tested in a Visual Basic program, the condition either is true or false

5 Chapter 5: Mobile Applications Using Decision Structures28 Relational Operators

5 Chapter 5: Mobile Applications Using Decision Structures29 Relational Operators ►With the insertion point located in the correct location within the code you are writing, type if on your keyboard and then press the SPACEBAR ►Press CTRL+SPACEBAR to invoke IntelliSense. Type inta to select the variable named intAge in the IntelliSense list. Then, type >=21 as the condition to be tested. Press the ENTER key ►On the blank line, enter the statement that should be executed when the condition is true. To place the message, “You are old enough to vote” in the Text property of the lblVotingEligibility Label object, insert the code shown in Figure 5-41 on page 316. Remember to use IntelliSense to reference the lblVotingEligibility Label object

5 Chapter 5: Mobile Applications Using Decision Structures30 Relational Operators

5 Chapter 5: Mobile Applications Using Decision Structures31 Comparing Strings ►A string value comparison compares each character in two strings, starting with the first character in each string

5 Chapter 5: Mobile Applications Using Decision Structures32 Comparing Different Data Types ►Every type of data available in Visual Basic can be compared Different numeric types can be compared to each other A single string character can be compared to a Char data type

5 Chapter 5: Mobile Applications Using Decision Structures33 Using the If…Then…Else Statement

5 Chapter 5: Mobile Applications Using Decision Structures34 Using the If…Then…ElseIf Statement

5 Chapter 5: Mobile Applications Using Decision Structures35 Nested If Statements

5 Chapter 5: Mobile Applications Using Decision Structures36 Nested If Statements

5 Chapter 5: Mobile Applications Using Decision Structures37 Matching If, Else, and End If Entries ►If statements must be fully contained within the outer If statement ►Place the correct statements with the correct If and Else statements within the nested If statement This illustration shows incorrect logic

5 Chapter 5: Mobile Applications Using Decision Structures38 Testing the Status of a RadioButton Object in Code

5 Chapter 5: Mobile Applications Using Decision Structures39 Block-Level Scope ►Scope is defined by where the variable is declared within a program ►Within an event handler, an If…Then…Else statement is considered a block of code ►Variables can be declared within a block of code The variable can be referenced only within the block of code where it is declared

5 Chapter 5: Mobile Applications Using Decision Structures40 Using Logical Operators ►When more than one condition is included in an If...Then...Else statement, the conditions are called a compound condition

5 Chapter 5: Mobile Applications Using Decision Structures41 Using the And Logical Operator

5 Chapter 5: Mobile Applications Using Decision Structures42 Using the Or Logical Operator

5 Chapter 5: Mobile Applications Using Decision Structures43 Using the Not Logical Operator

5 Chapter 5: Mobile Applications Using Decision Structures44 Other Logical Operators

5 Chapter 5: Mobile Applications Using Decision Structures45 Order of Operations for Logical Operators

5 Chapter 5: Mobile Applications Using Decision Structures46 Select Case Statement ►In some programming applications, different operations can occur based upon the value in a single field

5 Chapter 5: Mobile Applications Using Decision Structures47 Select Case Statement

5 Chapter 5: Mobile Applications Using Decision Structures48 Select Case Test Expressions

5 Chapter 5: Mobile Applications Using Decision Structures49 Using Relational Operators in a Select Case Statement

5 Chapter 5: Mobile Applications Using Decision Structures50 Using Ranges in Select Case Statements

5 Chapter 5: Mobile Applications Using Decision Structures51 Selecting Which Decision Structure to Use ►You might be faced with determining if you should use the Select Case statement or the If...Then...ElseIf statement to solve a problem ►Generally, the Select Case statement is most useful when more than two or three values must be tested for a given variable ►The If...Then...ElseIf statement is more flexible More than one variable can be used in the comparison Compound conditions with the And, Or, and Not logical operators can be used

5 Chapter 5: Mobile Applications Using Decision Structures52 Code Snippets ►Right-click the line in the code editing window where you want to insert the snippet ►Click Insert Snippet on the shortcut menu ►Double-click Common Code Patterns, which is a folder that contains commonly used code such as the If...Then...Else statement ►Double-click the Conditionals and Loops folder because an If...Then...Else statement is a conditional statement ►Double-click the If...Else...End If Statement code snippet

5 Chapter 5: Mobile Applications Using Decision Structures53 Code Snippets

5 Chapter 5: Mobile Applications Using Decision Structures54 Validating Data ►Developers should anticipate that users will enter invalid data ►Developers must write code that will prevent the invalid data from being used in the program to produce invalid output

5 Chapter 5: Mobile Applications Using Decision Structures55 Testing Input to Determine If the Value Is Numeric ►The Visual Basic IsNumeric function can check the input value to determine if the value can be converted into a numeric value such as an Integer or Decimal data type

5 Chapter 5: Mobile Applications Using Decision Structures56 Checking for a Positive Number

5 Chapter 5: Mobile Applications Using Decision Structures57 Deploying the Application ►With Visual Studio open and the program you want to run loaded, click the Start Debugging button on the Standard toolbar ►If necessary, select Pocket PC 2003 SE Emulator in the Device list. Click the Deploy button ►After the Wood Cabinet Estimate application loads and executes on the emulator device, type 15 in the Linear Feet text box ►Using your mouse, click the Oak radio button, and then click the Calculate button

5 Chapter 5: Mobile Applications Using Decision Structures58 Deploying the Application

5 Chapter 5: Mobile Applications Using Decision Structures59 Using the Input Panel ►When you use the emulator, you can enter data directly from the keyboard ►The Pocket PC has the input panel to enter data into applications You can use a stylus to select the characters from the input panel. When you press the stylus on a character in the input panel, the character is entered into the focused object on the form

5 Chapter 5: Mobile Applications Using Decision Structures60 Closing the Emulator ►When you are finished with the application, close the emulator by clicking the Close button (X) in the upper-right corner of the Pocket PC emulator ►It is critical that you click the No button

5 Chapter 5: Mobile Applications Using Decision Structures61 Summary ►Write programs for devices other than a personal computer ►Understand the use of handheld technology ►Write handheld applications for a Personal Digital Assistant ►Use the Panel object ►Place RadioButton objects in applications

5 Chapter 5: Mobile Applications Using Decision Structures62 Summary ►Display a message box ►Make decisions using If…Then statements ►Make decisions using If…Then…Else statements ►Make decisions using nested If statements

5 Chapter 5: Mobile Applications Using Decision Structures63 Summary ►Make decisions using logical operators ►Make decisions using Case statements ►Insert code snippets ►Test input to ensure a value is numeric

Microsoft Visual Basic 2005 CHAPTER 5 COMPLETE Mobile Applications Using Decision Structures