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.
Work with enum values - Visual Basic Tutorial
From the course: Visual Basic Essential Training
Work with enum values
- [Instructor] We've heard about classes and modules earlier in this course. Another type we can create is the Enum type. Enums allow us to create a group of related constants under a single name. Think of Enums as a way to make our code more descriptive and easier to maintain. Because they are a type, not a simple constant, we can use the Enum type as our variable type. On line 53, I'm declaring the current day variable as the day of the week type, which is a .NET library type. So then, on line 54, when I'm writing my code, I get a list of the possible Enum values. Even better, when I turn Option Strict on, the compiler ensures that only Enum values are assigned to that variable, so there is no possibility of a runtime error. I'm working with some of the Enums that are part of .NET, starting with the day of the week, which we saw on the slides. Here, I'm declaring a variable called Dim currentDay. I specify the Enum type DayOfWeek, and then here I'm assigning one of the enumeration…
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)
-
-
-
-
-
-
-
-
-
-
-
-