Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 41 Sub Procedures, Part II (Continue). Chapter 42 Local Variable A variable declared inside a Sub procedure with a Dim statement Space reserved.

Similar presentations


Presentation on theme: "Chapter 41 Sub Procedures, Part II (Continue). Chapter 42 Local Variable A variable declared inside a Sub procedure with a Dim statement Space reserved."— Presentation transcript:

1 Chapter 41 Sub Procedures, Part II (Continue)

2 Chapter 42 Local Variable A variable declared inside a Sub procedure with a Dim statement Space reserved in memory for that variable until the End Sub – then the variable ceases to exist

3 Chapter 43 Local Variables Private Sub btnOne_Click(...) Handles btnOne_Click Dim num As Integer = 4 SetFive() txtBox.Text = CStr(num) End Sub Sub SetFive() Dim num As Integer = 5 End Sub Output: 4

4 Chapter 44 Class-Level Variables Visible to every procedure in a form’s code without being passed Dim statements for class-level variables are placed Outside all procedures At the top of the program region

5 Chapter 45 Class-Level Variables Dim num As Integer = 4 Private Sub btnOne_Click(...) Handles btnOne_Click txtBox.Text = CStr(num) SetFive() txtBox.Text = CStr(num) End Sub Sub SetFive() num = 5 End Sub Output: 5

6 Chapter 46 Scope The scope of a variable is the portion of the program that can refer to it.

7 Chapter 47 Scope Class-level variables have class-level scope and are available to all procedures in the class. Variables declared inside a procedure have local scope and are only available to the procedure in which they are declared.


Download ppt "Chapter 41 Sub Procedures, Part II (Continue). Chapter 42 Local Variable A variable declared inside a Sub procedure with a Dim statement Space reserved."

Similar presentations


Ads by Google