From the course: Visual Basic Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Work with custom and built-in constants

Work with custom and built-in constants - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

Work with custom and built-in constants

- [Instructor] Now it's time to look at constants in your code. I'll be looking at the code here on line eight and nine where I declare two of my own custom constants. Now typically, when you create a constants, you usually declare them at the class level, like up here, or at the module level. For this demonstration, though, I'm keeping them as local constants. Line eight has the declaration. You start with the Const keyword, then the identifier, then your data type, and then you specify the initializer. You have to have an initializer, when you create a constant. On this line I'm initializing it with the numbers of Pi, on the second line on line nine, I'm creating a constants called HALF_BYTE and I'm initializing it with half the distance between zero and 256 for a byte. Let's talk about the data types. This is a decimal data type, it's the most accurate floating point type in Visual Basic. Very useful when you have data…

Contents