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.
Create custom constants - Visual Basic Tutorial
From the course: Visual Basic Essential Training
Create custom constants
- [Instructor] Declaring a constant is straightforward. You use the constant keyword, C-O-N-S-T, instead of the dim keyword. Now, typically constants are declared either at the class level or more likely they're declared in a module. Modules are shared across multiple files, so if you put your constants in a module, then you can use it throughout your project. So here's an example of how I would do that. I'm declaring a public constant in my class that is called DocFileExtension. It's a string, and here's the value that's assigned to that constant. Remember that once the value is assigned, you can't change the value. Here's an example where I'm doing a local constant. That's very rare, you don't typically see that, but I did it for the demonstration. Want to talk about names here. This is Microsoft's suggested naming convention, which is Pascal casing, where every letter in the word is capitalized. But you'll see this line of code, line nine, you'll see this a lot in classic visual…
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)
-
-
-
-
-
-
-
-
-
-
-
-