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

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