Lect03 Introducing Variables, Memory Concepts, and Arithmetic
Lect03 Introducing Variables, Memory Concepts, and Arithmetic
T U T O R I A L
Enhancing the
6
Inventory
Application
Introducing Variables, Memory
Concepts and Arithmetic
Outline
Objectives
Figure 6.1 | Inventory application GUI displayed when the application runs.
Figure 6.3 | Enhanced Inventory application clears output Label after new input.
6.2 Variables
Variable declarations
Calculating and
displaying the result
Result of
calculation
Figure 6.9 | TextChanged event handler for Cartons per shipment: TextBox.
Figure 6.10 | TextChanged event handler for Items per carton: TextBox.
(2 of 2 )
19 ' display result in Label Assigning a
20 totalResultLabel.Text = result variable’s value
21 End Sub ' calculateButton_Click to a property
22
23 ' handles TextChanged event for cartonsTextBox
24 Private Sub cartonsTextBox_TextChanged(ByVal sender As _
25 System.Object, ByVal e As System.EventArgs) _
26 Handles cartonsTextBox.TextChanged
27
Setting a Label’s Text
28 totalResultLabel.Text = "" ' clear output Label
property to an empty string
29 End Sub ' cartonsTextBox_TextChanged
30
31 ' handles TextChanged event for itemsTextBox
32 Private Sub itemsTextBox_TextChanged(ByVal sender As _
33 System.Object, ByVal e As System.EventArgs) _
34 Handles itemsTextBox.TextChanged
35
36 totalResultLabel.Text = "" ' clear output Label
37 End Sub ' itemsTextBox_TextChanged
38 End Class ' InventoryForm
Figure 6.12 | Memory location showing name and value of variable cartons.
6.5 Arithmetic
Subtraction – p–c p - c
Multiplication * bm b * m
Division (float) / x x / y
x y or or x ÷ y
y
Division (integer) \ none v \ u
Exponentiation ^ qp q ^ p
Unary Negative - –e –e
Unary Positive + +g +g
Breakpoints
Breakpoints
Figure 6.20 | Displaying a variable value by placing the mouse pointer over a variable name.
Disabled breakpoint