Mgmt 362a Enhancing the Inventory Application - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

Mgmt 362a Enhancing the Inventory Application

Description:

Solid maroon circle appears for each breakpoint ... Select Breakpoint Remove Breakpoint. Or click the maroon circle in the margin indicator bar ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 43
Provided by: Pear179
Category:

less

Transcript and Presenter's Notes

Title: Mgmt 362a Enhancing the Inventory Application


1
6
  • Mgmt 362a Enhancing the Inventory Application
  • Introducing Variables, Memory Concepts and
    Arithmetic

2
Outline
  • 6.1 Test-Driving the Enhanced Inventory
    Application
  • 6.2 Variables
  • 6.3 Handling the TextChanged Event
  • 6.4 Memory Concepts
  • 6.5 Arithmetic
  • 6.6 Using the Debugger Breakpoints
  • 6.7 Internet and Web Resources
  • 6.8 Wrap-Up

3
Objectives
  • In this tutorial you will learn
  • Create variables.
  • Handle the TextChanged event.
  • Apply basic memory concepts using variables.
  • Use the precedence rules of arithmetic operators.
  • Set breakpoints to debug applications.

4
6.1 Test-Driving the Enhanced Inventory
Application
  • The inventory manager notices a flaw in your
    Inventory application. Although the application
    calculates the correct result, that result
    continues to display even after new data is
    entered. The only timethe output changes is when
    the inventory manager clicks theCalculate Button
    again. You need to alter the Inventory
    applicationto clear the result as soon as the
    user enters new information intoeither of the
    TextBoxes, to avoid any confusion over the
    accuracy of your calculated result.

5
6.1 Test-Driving the Enhanced Inventory
Application (Cont.)
  • Figure 6.1 Inventory application GUI displayed
    when the application runs.

Running the application
6
6.1 Test-Driving the Enhanced Inventory
Application (Cont.)
  • Figure 6.2 Running the Inventory application.
  • Using the application
  • Enter data into the TextBoxes and click the
    Calculate Total Button
  • Notice the result

7
6.1 Test-Driving the Enhanced Inventory
Application (Cont.)
  • Figure 6.3 Enhanced Inventory application
    clears output Label after new input.
  • Notice the new feature
  • The output Label is cleared when new data is
    entered

8
6.2 Variables
  • Adding code to the application
  • Declaring a variable
  • Keyword Dim
  • Data types
  • Built-in data type
  • Primitive data type

9
Good Programming Practice
  • Typically, variable-name identifiers begin witha
    lowercase letter. Every word in the name
    afterthe first word should begin with a capital
    letter,for example, firstNumber.

10
Good Programming Practice
  • Use only letters and digits as characters
    foryour variable names.

11
6.2 Using Variables in the Inventory Application
  • Figure 6.4 Declaring variables in event handler
    calculateButton_Click.

12
6.2 Using Variables in the Inventory Application
(Cont.)
  • Retrieving data from the user
  • Data is stored in the TextBoxs Text property
  • The Val function
  • Returns data type Double
  • Implicit conversion

13
6.2 Using Variables in the Inventory Application
(Cont.)
  • Figure 6.5 Retrieving numerical input from
    TextBoxes.

14
6.2 Using Variables in the Inventory Application
(Cont.)
  • Figure 6.6 Visual Basic built-in data types.

15
6.2 Using Variables in the Inventory Application
(Cont.)
  • Perform the multiplication
  • Displaying the result
  • Set the multiplication result to the Labels Text
    property

16
6.2 Using Variables in the Inventory Application
(Cont.)
  • Figure 6.7 Multiplication, using variables in
    calculateButton_Click.

17
6.2 Using Variables in the Inventory Application
(Cont.)
  • Figure 6.8 Displaying the multiplication result
    using variables.
  • Running the application
  • Enter data
  • Click the Calculate Total Button
  • Notice the result

18
6.3 Handling the TextChanged Event
  • Create the event handler for the first TextBox
  • Double click the TextBox
  • TextChanged event handler is created
  • Clearing the value
  • Use empty string
  • Repeat for second TextBox

19
6.3 Handling the TextChanged Event (Cont.)
  • Figure 6.9 TextChanged event handler for
    Cartons per shipment TextBox.

20
Good Programming Practice
  • If a statement is wider than the code editor
    window, use the line-continuation character
    within the statement to continue it on the next
    line.

21
6.3 Handling the TextChanged Event (Cont.)
  • Figure 6.10 TextChanged event handler for Items
    per carton TextBox.

22
Outline
(1 of 2 )
Use keyword Dim to declare variables inside an
event handler
Assigning a propertys valueto a variable
Assigning a variableto a property
23
Outline
(2 of 2 )
Setting a TextBoxs Text property to an empty
string
24
6.4 Memory Concepts
  • Figure 6.12 Memory location showing name and
    value of variable cartons.
  • A simple variable
  • Corresponds to actual location in the computers
    memory
  • Name
  • Type
  • Size
  • Value

25
6.4 Memory Concepts (Cont.)
  • Figure 6.13 Memory locations after values for
    variables cartons anditems have been input.
  • Visualizing data
  • The value of each variable is stored in a
    separate memory location

26
6.4 Memory Concepts (Cont.)
  • Figure 6.14 Memory locations after a
    multiplication operation.
  • Using the variables data
  • Nondestructive when value is read from memory

27
6.5 Arithmetic
  • Operator precedence
  • Operators in expressions contained within a pair
    of parentheses are evaluated first
  • Exponentiation is applied next
  • Unary positive and negative are applied
  • Multiplication and floating-point division
    operations
  • Division is applied
  • Modulus operations are second to last
  • Lastly, Addition and subtraction operations

28
6.5 Arithmetic (Cont.)
Figure 6.15 Arithmetic operators.
29
Common Programming Error
  • Attempting to divide by zero is a runtime
    error(that is, an error that has its effect
    while the application executes). Dividing by
    zeroterminates an application.

30
Good Programming Practice
  • Using redundant parentheses in complex arithmetic
    expressions can make the expressions easier to
    read.

31
6.6 Using the Debugger Breakpoints
  • Methods of inserting breakpoints
  • Click inside the margin indicator bar
  • Right click the line of code and select
    Breakpoint gt Insert Breakpoint
  • Breakpoints
  • You can set as many as you like
  • Solid maroon circle appears for each breakpoint
  • Can be set during design more, break mode, or run
    mode

32
6.6 Using the Debugger Breakpoints (Cont.)
  • Figure 6.16 Setting two breakpoints.

33
6.6 Using the Debugger Breakpoints (Cont.)
  • Figure 6.17 Inventory application running.

Run the application Click the Calculate Total
Button
34
6.6 Using the Debugger Breakpoints (Cont.)
  • Figure 6.18 Title bar of the IDE displaying
    (Debugging).

The IDE title bar displays the applications mode
35
6.6 Using the Debugger Breakpoints (Cont.)
  • Debugging the application
  • Program execution suspends at the first break
    point
  • Yellow arrow indicate next statement to execute

36
6.6 Using the Debugger Breakpoints (Cont.)
  • Figure 6.19 Application execution suspended at
    the first breakpoint.

37
6.6 Using the Debugger Breakpoints (Cont.)
  • To resume execution, select Debug gt Continue
  • The application continues its normal execution
  • Quick Info box
  • Displays variables current value

38
6.6 Using the Debugger Breakpoints (Cont.)
  • Figure 6.20 Displaying a variable value by
    placing the mouse pointer overa variable name.

39
6.6 Using the Debugger Breakpoints (Cont.)
  • Figure 6.21 Application output.
  • Use the Debug gt Continue command to complete the
    application
  • No more breakpoints, program will not suspend
  • The entire application executes to completion

40
6.6 Using the Debugger Breakpoints (Cont.)
  • Disabling a breakpoint
  • Right click the line of code with the breakpoint
  • Select Breakpoint gt Disable Breakpoint
  • A hollow maroon circle indicates disabled
    breakpoint

41
6.6 Using the Debugger Breakpoints (Cont.)
  • Figure 6.22 Disabled breakpoint.

42
6.6 Using the Debugger Breakpoints (Cont.)
  • Removing a breakpoint
  • Right click the line of code with the breakpoint
  • Select Breakpoint gt Remove Breakpoint
  • Or click the maroon circle in the margin
    indicator bar
Write a Comment
User Comments (0)
About PowerShow.com