Learning MicroStation VBA

Chapter 12: The MicroStation Object Model - Enums

What is an Enum? Enum is an abbreviation for enumeration, a collection of constants that can be used in our code.

Let's consider the following enumeration:

MsddesignFileFormat

msdDesignFileFormatCurrent = 0msdDesignFileFormatDWG = 3msdDesignFileFormatDXF = 4msdDesignFileFormatUnknown = -1msdDesignFileFormatV7 = 1msdDesignFileFormatV8 = 2

The enumeration name is "MsdDesignFileFormat". It has six members with values ranging from -1 to 4. Each member in an enumeration has a name and a value. The enumeration member "msdDesignFileFormatCurrent" has a value of 0. As we saw in the previous chapter, some properties and methods make use of these enumerations. For example,

Sub SaveAs(NewFileName As String, [Overwrite As _ Boolean = False], [NewFormat As MsdDesignFileFormat _= msdDesignFileFormatCurrent])

The SaveAs method is found under the DesignFile object. When we use it, we can specify a file name, whether an existing file should be overwritten, and the file format to be used. The data type for "NewFileName" is String. The value type for "Overwrite" is Boolean. The value type for "NewFormat" is MsdDesignFileFormat. The "NewFormat" parameter utilizes the "MsdDesignFileFormat" enumeration. As we use the SaveAs method, we see the following:

While working in VBA, when we come to a parameter that utilizes an enumeration, we see the list of the members of that enumeration. We are not shown the value of each member.

Enumerations provide several benefits, with one of the largest being that we can more easily see the desired parameter results as we look at our code. In other words, seeing "msdDesignFileFormatDWG" is clearer than seeing the...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Barcode Decoders
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.