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

Similar documents
Microsoft Visual Basic 2005 CHAPTER 6. Loop Structures

Visual Basic Program Coding STEP 2

You will have mastered the material in this chapter when you can:

Text box. Command button. 1. Click the tool for the control you choose to draw in this case, the text box.

Status Bar: Right click on the Status Bar to add or remove features.

Program and Graphical User Interface Design

Power Point 2000 Level 1

INTRODUCTION TO VISUAL BASIC 2010

Discovering Computers & Microsoft Office Office 2010 and Windows 7: Essential Concepts and Skills

INFORMATICS LABORATORY WORK #4

Word 2013 Quick Start Guide

Getting Started Manual. SmartList To Go

Chapter 2. Creating Applications with Visual Basic Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of

Display Systems International Software Demo Instructions

To complete this activity, you will need the following files:

LESSON B. The Toolbox Window

Tutorials. Lesson 3 Work with Text

Creating a Web Presentation

First Visual Basic Lab Paycheck-V1.0

Microsoft Excel Level 2

1) Merge the cells that contain the title and center the title

Introduction to the Visual Studio.NET Integrated Development Environment IDE. CSC 211 Intermediate Programming

Microsoft Office 2010: Introductory Q&As Access Chapter 2

Your First Windows Form

The Basics of PowerPoint

Section 1 Creating Mail Merge Files

6. Essential Spreadsheet Operations

Exporting distribution lists from Thunderbird to Outlook

PowerPoint Basics. Objectives. PowerPoint Basics. Just what are we trying to do with this software anyway?

TABLE OF CONTENTS TABLE OF CONTENTS... 1 INTRODUCTION... 2 USING WORD S MENUS... 3 USING WORD S TOOLBARS... 5 TASK PANE... 9

Microsoft Access 2013

To complete this project, you will need the following folder:

EXCEL 2003 DISCLAIMER:

ekaizen Lessons Table of Contents 1. ebook Basics 1 2. Create a new ebook Make Changes to the ebook Populate the ebook 41

Navigate to Cognos Cognos Analytics supports all browsers with the exception of Microsoft Edge.

GUI Design and Event- Driven Programming

Using Common Features of Microsoft Office Explore Microsoft Office Start programs and switch between them. Tutorial 1

SQL Server. Management Studio. Chapter 3. In This Chapter. Management Studio. c Introduction to SQL Server

Introduction to Microsoft Excel 2016

BasicScript 2.25 User s Guide. May 29, 1996

Microsoft Excel Chapter 3. Working with Large Worksheets, Charting, and What-If Analysis

NiceForm User Guide. English Edition. Rev Euro Plus d.o.o. & Niceware International LLC All rights reserved.

Dive Into Visual C# 2010 Express

MODIFYING CIRCULATION WINDOW DISPLAYS

PowerPoint Essentials 1

Office 365: . Accessing and Logging In. Mail

Excel Select a template category in the Office.com Templates section. 5. Click the Download button.

Skill Exam Objective Objective Number. Setting Page Layout Modify page setup

Visual Basic 2008 Anne Boehm

Beginning PowerPoint: 2010 A Presentation Software

2 USING VB.NET TO CREATE A FIRST SOLUTION

4. In the Change Chart Type dialog box, click the type of chart to which you want to change. 5. Click the chart style. 6. Click OK.

How to set up an Amazon Work Profile for Windows 8

Premiere - Jazz Video Project Tutorial

PowerPoint Essentials

Part I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations

2 TUTORIAL. Overview. VisualDSP Getting Started Guide 2-1 for SHARC DSPs

A Quick Tour GETTING STARTED WHAT S IN THIS CHAPTER?

Lesson 12 Getting Started with Word Essentials

Window Designer. Opening Screen: When you start Window Designer, you will see the Opening Screen. Here you will be choosing from 4 options:

Microsoft Visio 2010

2.1 Logging on to FieldManager Software

HOUR 4 Understanding Events

SharePoint: Fundamentals

Using Microsoft Excel

COMSC-031 Web Site Development- Part 2. Part-Time Instructor: Joenil Mistal

Microsoft Access 2003 Quick Tutorial

SharePoint: Fundamentals

Bold, Italic and Underline formatting.

Dive Into Visual C# 2008 Express

Basic Concepts. Launching MultiAd Creator. To Create an Alias. file://c:\documents and Settings\Gary Horrie\Local Settings\Temp\~hh81F9.

Microsoft Publisher 2010 Tecumseh District Library

ECDL Module 4 REFERENCE MANUAL

Microsoft. An Introduction

Simply Personnel Screen Designer

Using Visual Basic Studio 2008

Scripting with CAMMaster and Visual Basic 2008

Workbook Also called a spreadsheet, the Workbook is a unique file created by Excel. Title bar

Using Microsoft Excel

PowerPoint Launching PowerPointX

Advanced Excel. Click Computer if required, then click Browse.

Setting Accessibility Options in Windows 7

Links to Activities ACTIVITY 3.1. Links to Activities

Quick Tips & Tricks. Important You must use SEMICOLONS ( ie; ) to separate address when sending mail to multiple users

MS Word Basics. Groups within Tabs

M Introduction to Visual Basic.NET Programming with Microsoft.NET 5 Day Course

VB.NET. Exercise 1: Creating Your First Application in Visual Basic.NET

Microsoft PowerPoint 2010 Beginning

Linear Control Systems LABORATORY

Copyright 2015 Integrated Environmental Solutions Limited. All rights reserved.

Intro to Excel. To start a new workbook, click on the Blank workbook icon in the middle of the screen.

Using Microsoft Word. Paragraph Formatting. Displaying Hidden Characters

How to Spice Up Your Forms Using Crystal

KEYBOARD SHORTCUTS AND HOT KEYS

Table of Contents. Chapter 2. Looking at the Work Area

Copyright. Trademarks Attachmate Corporation. All rights reserved. USA Patents Pending. WRQ ReflectionVisual Basic User Guide

Correcting Grammar as You Type

SUM - This says to add together cells F28 through F35. Notice that it will show your result is

FrontPage. Directions & Reference

Word Select New in the left pane. 3. Select Blank document in the Available Templates pane. 4. Click the Create button.

Transcription:

Microsoft Visual Basic 2005 CHAPTER 5 Mobile Applications Using Decision Structures

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 Chapter 5: Mobile Applications Using Decision Structures 2

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

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

Chapter Project Chapter 5: Mobile Applications Using Decision Structures 5

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

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 Chapter 5: Mobile Applications Using Decision Structures 7

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

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 Chapter 5: Mobile Applications Using Decision Structures 9

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

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 Chapter 5: Mobile Applications Using Decision Structures 11

Using the Panel Object Chapter 5: Mobile Applications Using Decision Structures 12

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 Chapter 5: Mobile Applications Using Decision Structures 13

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 Chapter 5: Mobile Applications Using Decision Structures 14

Adding the RadioButton Objects Chapter 5: Mobile Applications Using Decision Structures 15

Windows Application Container Objects Chapter 5: Mobile Applications Using Decision Structures 16

Displaying a Message Box Chapter 5: Mobile Applications Using Decision Structures 17

Displaying a Message Box Chapter 5: Mobile Applications Using Decision Structures 18

Displaying a Message Box Chapter 5: Mobile Applications Using Decision Structures 19

Displaying a Message Box Chapter 5: Mobile Applications Using Decision Structures 20

Displaying a Message Box Chapter 5: Mobile Applications Using Decision Structures 21

Displaying a Message Box Chapter 5: Mobile Applications Using Decision Structures 22

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, Chapter 5: Mobile Applications Using Decision Structures 23

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 Chapter 5: Mobile Applications Using Decision Structures 24

Displaying a Message Box Chapter 5: Mobile Applications Using Decision Structures 25

Displaying a Message Box Chapter 5: Mobile Applications Using Decision Structures 26

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 Chapter 5: Mobile Applications Using Decision Structures 27

Relational Operators Chapter 5: Mobile Applications Using Decision Structures 28

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 Chapter 5: Mobile Applications Using Decision Structures 29

Relational Operators Chapter 5: Mobile Applications Using Decision Structures 30

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

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 Chapter 5: Mobile Applications Using Decision Structures 32

Using the If Then Else Statement Chapter 5: Mobile Applications Using Decision Structures 33

Using the If Then ElseIf Statement Chapter 5: Mobile Applications Using Decision Structures 34

Nested If Statements Chapter 5: Mobile Applications Using Decision Structures 35

Nested If Statements Chapter 5: Mobile Applications Using Decision Structures 36

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 Chapter 5: Mobile Applications Using Decision Structures 37

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

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 Chapter 5: Mobile Applications Using Decision Structures 39

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

Using the And Logical Operator Chapter 5: Mobile Applications Using Decision Structures 41

Using the Or Logical Operator Chapter 5: Mobile Applications Using Decision Structures 42

Using the Not Logical Operator Chapter 5: Mobile Applications Using Decision Structures 43

Other Logical Operators Chapter 5: Mobile Applications Using Decision Structures 44

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

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

Select Case Statement Chapter 5: Mobile Applications Using Decision Structures 47

Select Case Test Expressions Chapter 5: Mobile Applications Using Decision Structures 48

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

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

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 Chapter 5: Mobile Applications Using Decision Structures 51

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 Chapter 5: Mobile Applications Using Decision Structures 52

Code Snippets Chapter 5: Mobile Applications Using Decision Structures 53

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 Chapter 5: Mobile Applications Using Decision Structures 54

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 Chapter 5: Mobile Applications Using Decision Structures 55

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

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 Chapter 5: Mobile Applications Using Decision Structures 57

Deploying the Application Chapter 5: Mobile Applications Using Decision Structures 58

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 Chapter 5: Mobile Applications Using Decision Structures 59

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 Chapter 5: Mobile Applications Using Decision Structures 60

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 Chapter 5: Mobile Applications Using Decision Structures 61

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

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

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