From the course: Visual Basic Essential Training
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Understand the variable scope: What code can access the variable - Visual Basic Tutorial
From the course: Visual Basic Essential Training
Understand the variable scope: What code can access the variable
- [Instructor] When you think about variables, it's important to understand two concepts. The scope of the variable and the lifetime of the variable. Scope determines the visibility of that variable to other parts of your code. In other words, where can I use that variable? Lifetime refers to how long the memory is kept available. Here's some information about scope and remember that's the visibility of the variable. Variables that are within the same scope cannot share the same name. Lifetime depends on where the variable is declared. So let's start by talking about local variables. We'll talk about three types of variables, local variables, block level variables, and we'll also talk about class or module level variables. Starting with local variables. If I declare a variable within this procedure, the scope is all the code that in this procedure. So all the code that's in run code can see that variable. I'm declaring this cart counter here. That means I can use it elsewhere in my…
Contents
-
-
-
-
-
-
-
-
(Locked)
Work with variables and constants8m 17s
-
(Locked)
Use the code explorer project3m 26s
-
(Locked)
Declare a variable5m 35s
-
(Locked)
Variables and .NET types3m 36s
-
(Locked)
Naming your variables2m 19s
-
(Locked)
Understand the variable scope: What code can access the variable4m 19s
-
How data conversion works7m 49s
-
(Locked)
Convert numeric values5m 35s
-
(Locked)
Create custom constants1m 29s
-
(Locked)
Work with built-in constants3m 36s
-
(Locked)
Work with enum values3m 45s
-
(Locked)
Create a custom enum1m 35s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-
-