37
Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Embed Size (px)

Citation preview

Page 1: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Microsoft Visual Basic 2005

CHAPTER 12

Cell Phone Applications and Web Services

Page 2: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 2

12 Objectives

►Create a Smartphone application►Use a cell phone keypad for input►Enter input using a Smartphone►Enter other characters using the keypad►Add Smartphone Toolbox objects

Page 3: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 3

12 Objectives

►Create a softkey menu►Code the Smartphone application►Display MessageBox objects in a Smartphone

environment►Find Web services

Page 4: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 4

12 Objectives

►Create a Web service connection►Call a Web service method►Create a Crystal report►Display a Crystal report

Page 5: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 5

12 Introduction

Page 6: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 6

12 Creating a Smartphone Application

►With Visual Studio 2005 open, click the New Project button on the Standard toolbar, click Smart Device in the Project types pane on the left side of the New Project dialog box, and then, if necessary, click the plus sign next to Smart Device

►Click Smartphone 2003 under Smart Device in the Project types list. In the Templates pane, click Device Application (1.0)

►In the Name text box, change the name of the Smart Device application from DeviceApplication1 to TipCalculator. Click the OK button

Page 7: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 7

12 Creating a Smartphone Application

Page 8: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 8

12 Entering Input Using a Smartphone

► With the TipCalculator application open, name the Form object frmTip.vb. Title the Form object by changing the Text property to Tip Calculator. Add a Label object to the form named lblBillAmount. Change the Text property of the Label object to Amount of Bill. Drag a TextBox object under the Label object. Name the TextBox object txtBill. Clear the Text property. Resize the Label object to fit the text exactly. Center the Label and TextBox objects horizontally on the form

► Run the Smartphone application by clicking the Start Debugging button on the Standard toolbar

► Make sure Smartphone 2003 SE Emulator is selected, and then click the Deploy button

► To enter the bill amount of 75.22, press the 7 key on the keypad five times quickly. The letter “p” appears first, then the letter “q,” then the letter “r,” then the letter “s,” and lastly the number “7”. Next, press the 5 key on the keypad four times quickly to enter the number 5

Page 9: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 9

12 Entering Input Using a Smartphone

►To enter the decimal point, hold the # key in the lower-right corner of the keypad until the Symbols window opens

►To enter the decimal point, press the navigation keys, such as the right ARROW KEY and DOWN ARROW key, to move to the decimal point (period) in the Symbols window. To select the decimal point, press the Action key in the center of the navigation keys. Enter the digits 22 by first pressing the 2 key four times quickly. Wait a few seconds and press the 2 key four times quickly again to display the second 2

►To close the application, click the Close button in the upper-right corner of the program window

►Click the No button, and then click the OK button

Page 10: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 10

12 Entering Input Using a Smartphone

Page 11: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 11

12 Adding Smartphone Toolbox Objects

►If necessary, open the TipCalculator application, which includes the first Label and TextBox object on the form. Drag a second Label object named lblPercentage to the form below the TextBox object. Change the Text property to Tip Percentage. Drag the ComboBox object to the Form object below the second label. Name the ComboBox object cboTipPercent. Click the ellipsis button to the right of the Items property. Enter the three tip percentage amounts into the String Collection Editor: 10% (press ENTER), 15% (press ENTER), and 20%. Resize the objects to the exact size of the text. Center both the Label and ComboBox objects on the center of the form

Page 12: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 12

12 Adding Smartphone Toolbox Objects

►Run the Smartphone application by clicking the Start Debugging button on the Standard toolbar. In the Deploy TipCalculator window, make sure the Smartphone 2003 SE Emulator option is selected, and then click the Deploy button. When the Smartphone emulator opens and loads the application, enter 75.22 in the first TextBox object using the keypad. To move to the ComboBox object for input, click the down arrow key on the navigation keypad. To view the ComboBox items, click the right arrow on the navigation keypad; 10% is displayed in the ComboBox object. Click the right arrow again to view 15%. Select the 15% tip percentage by clicking the Action button in the center of the navigation keypad. Close the Smartphone emulator without saving the emulator state

Page 13: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 13

12 Adding Smartphone Toolbox Objects

Page 14: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 14

12 Creating a Softkey Menu

►On the frmTip Form object of the TipCalculator application, click the left side of the Command control area

►Type Compute Tip in the Command control area. Press ENTER. Use the (Name) property to name the Command control area mnuComputeTip

Page 15: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 15

12 Coding the Smartphone Application

►In the TipCalculator application, double-click the mnuComputeTip Command control area in the lower-left corner of the Smartphone Form object

►Enter the code shown on the following slide to compute the tip for the restaurant bill amount

Page 16: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 16

12 Coding the Smartphone Application

Page 17: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 17

12 Program Design

Page 18: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 18

12 Program Design

Page 19: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 19

12 Designing the Program Processing Objects

Page 20: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 20

12 Finding Web Services

►With a new Windows Form object open with the project name CurrencyConverter, right-click the project name CurrencyConverter in the Solution Explorer

►Select Add Web Reference on the shortcut menu►Enter the following Web service URL in the URL text box:

http://www.webservicex.net/CurrencyConvertor.asmx?wsdl. Then click the Go button to connect to the Web service. You must be connected to the Internet to find the Web service. If the Web service is available online, a message appears stating the name of the method that will be used in the code window to call the existing Web service

►Click the Add Reference button in the Ad Web Reference window

Page 21: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 21

12 Finding Web Services

Page 22: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 22

12 Creating a Web Services Connection

►After creating the Web reference, open the code window to create an instance of the Web service class. To create an instance named wsMoney (where ws stands for Web service), type Dim wsMoney as New net. You include the word net because the Web reference listed in the Solution Explorer begins with the name net

►To complete the name of the Web service, type a period and webservicex appears in the IntelliSense window. Select webservicex, type a period, and www appears in the IntelliSense window. Select www and type another period

►Select the Web service named CurrencyConvertor in the IntelliSense window. Press the ENTER key

Page 23: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 23

12 Creating a Web Services Connection

Page 24: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 24

12 Calling a Web Service Method

► In the code window, assign a Double data type variable named dblConversionAmount. The data type is assigned as a Double because the Web reference stated that the return type is a Double data type

► The variable dblConversionAmount is assigned to the returned value from the calling method ConversionRate. ConversionRate is method of the instance of wsMoney. Type dblC and press CTRL+SPACEBAR to complete the variable dblConversionRate. Type = wsMoney. An IntelliSense list opens. Select ConversionRate, and then type a left parenthesis (

► To convert U.S. dollars to euros, scroll down the list of first arguments and select net.webservicex.www.Currency.USD. Type a comma and the second list of arguments appears. Scroll down the list of second arguments and select net.webservicex.www.Currency.EUR for euros. Type a closing parenthesis

Page 25: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 25

12 Calling a Web Service Method

Page 26: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 26

12 Program Design

Page 27: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 27

12 Program Design

Page 28: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 28

12 Designing the Program Processing Objects

Page 29: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 29

12 Crystal Reports:Creating a Report

►Open Visual Studio using the Start button on the Windows taskbar and the All Programs submenu. Click the New Web Site button on the Standard toolbar. In the list of Visual Studio installed templates, click ASP.NET Web Site. Name the sample report PhysicianReferral. Click the OK button

►Right-click the project name PhysicianReferral in the Solution Explorer, and then click Add New Item on the shortcut menu. When the Add New Item window opens, click Crystal Report in the list of installed templates

►Click the Add button

Page 30: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 30

12 Crystal Reports:Creating a Report

► Click the OK button. Download the database named physicians.mdb from the scsite.com/vb2005/ch12 to a removable disk, such as a USB drive. Click the plus sign in front of Create New Connection to expand the options. Click the plus sign in front of Database Files. Browse to the physicians.mdb database and select the file. Click the Open button. Select the PhysicianList table and then click the Add (>) button in the center of the window

► Click the Next button. In the Fields dialog box of the Standard Report Creation Wizard, hold down the CTRL key and select the Physician Name, City, State, and Specialty fields. Click the Add (>) button in the center of the form

► Click the Next button. Click the Next button again to create a report without any groupings. Click the Next button again to create a report without a summary. If necessary, click the Next button again to create a report without any subsets. In the Report Style window, select the Red/Blue Border style

► Click the Finish button

Page 31: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 31

12 Crystal Reports:Creating a Report

Page 32: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 32

12 Displaying the Report

►Click the Default.aspx tab to open the Web form. Open the Crystal Reports category on the Toolbox by clicking the plus sign to expand the Crystal Reports category. Drag the CrystalReportViewer object onto the Default.aspx Web form

►If necessary, click the action button on the CrystalReportViewer object, and then click the Choose Report Source list arrow. Select <New Report Source...>. The Create Report Source window opens. Click the Specify Crystal Report for the CrystalReportSource control list arrow, and then select CrystalReport.rpt

►Click the OK button. Click the Start Debugging button on the Standard toolbar to execute the Web page. On the Debugging Not Enabled window, click the OK button

Page 33: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 33

12 Displaying the Report

Page 34: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 34

12 Summary

►Create a Smartphone application►Use a cell phone keypad for input►Enter input using a Smartphone►Enter other characters using the keypad►Add Smartphone Toolbox objects

Page 35: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 35

12 Summary

►Create a softkey menu►Code the Smartphone application►Display MessageBox objects in a Smartphone

environment►Find Web services

Page 36: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Chapter 12: Cell Phone Applications and Web Services 36

12 Summary

►Create a Web service connection►Call a Web service method►Create a Crystal report►Display a Crystal report

Page 37: Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services

Microsoft Visual Basic 2005

CHAPTER 12 COMPLETE

Cell Phone Applicationsand Web Services