Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Lecture #3 CS 101 Autumn 2006 Tariq Jadoon.

Similar presentations


Presentation on theme: "Programming Lecture #3 CS 101 Autumn 2006 Tariq Jadoon."— Presentation transcript:

1

2 Programming Lecture #3 CS 101 Autumn 2006 Tariq Jadoon

3 In Lecture #2 Variables and Assignment statements New Controls –Label –CommandButton –Textbox

4 Variables & Assignment Statements A variable is a named storage space –Naming variables follows certain simple rules: [See page 19 Chapter 2 of Visual Basic Schaum’s outline] Assignment statements assign values to variables: Variable = Expression An assignment statement is NOT an equation

5 1 4 Variables & Assignment Statements X = 1 X = 4 Y = X XY 4

6 Processor Variables & Assignment Statements 4 X = 1 X = 4 Y = X X = Y + 2 XY 4 4 + 2 =6 6

7 Today Swapping Variables Debugging Tools –Immediate Window –Single Stepping –Watch Conditional Statements

8 10 Swapping the Contents of Two Variables X = 10 Y = 20 XY 20

9 10 Swapping the Contents of Two Variables X = 10 Y = 20 X = Y XY 20

10 10 Swapping the Contents of Two Variables X = 10 Y = 20 Y = X XY 10 20

11 Swapping the Contents of Two Variables X = 10 Y = 20 Temp = Y Y = X X Y 10 20 Temp 20 10

12 Swapping the Contents of Two Variables X = 10 Y = 20 Temp = Y Y = X X = Temp X Y 10 Temp 20

13 Debugging Using the Immediate Window as a scratchpad Placing Breakpoints Single stepping (F8) Placing Watches

14 Conditional Code VB has a number of block structures for conditional code: IF condition THEN action IF condition THEN action1 action2... END IF

15 Conditional Code (contd.) IF condition THEN action1 … ELSE action2 … END IF


Download ppt "Programming Lecture #3 CS 101 Autumn 2006 Tariq Jadoon."

Similar presentations


Ads by Google