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 a custom enum - Visual Basic Tutorial
From the course: Visual Basic Essential Training
Create a custom enum
- [Instructor] The first thing we should look at when we're working on custom enums is where to declare the enumeration. The best place is to put it in a module. That's because code inside a module is shared by default across all the library. So that's what I've got here. I've created a module called WorkWithEnums. And what I wanted to show you here first is why enums are better. If you wanted to do constants for the four seasons, spring, summer, autumn, and winter, you would have to do code like this, and then there's no way to use this as a type in your code. That's not true for enumerations. I just use the enum keyword. I specify the name of the enum, I specify the names. And if I don't specify a number, then this will be zero and this will be one, and this will be two, and this will be three. But if I want, I can come in here and type in equal and put my own number in there if that's important. Most of the time it's not. So once I've defined my seasons enum, then I can go over to…
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)
-
-
-
-
-
-
-
-
-
-
-
-