Home > Software engineering >  Visual Basic beginner for help
Visual Basic beginner for help

Time:06-05

Enum TosdType
Osd_text=0 '//Overlay cover
Osd_time//d=1 '
Osd_image=2 '//Offset screen
End Enum

What's the meaning of this passage? !

CodePudding user response:


Enum statement



Define an enumerated type,

Syntax

[Public | Private] Enum name

Membername [=constantexpression]

Membername [=constantexpression]

...

End Enum

Enum statement contains the following parts:

Part of the description
Public optional, said the Enum type is visible in the whole project, Enum type of default is Public,
Private optional, said the Enum type being declared in the module is only visible,
Name required, the name of the Enum type, the name must be a valid Visual Basic identifier, in defining the Enum type variable or parameter to specify the type with this name,
Membername required, the Enum type is used to specify the names of the constituent elements of Visual Basic legal identifier,
Constantexpression optional, the value of the element (Long), can be other Enum type, if you don't specify constantexpression, is assigned to the value or 0 (if the element is the first membername), or is greater than its immediate predecessor value 1,


Description

An enumeration variable, is refers to the use Enum type definitions of variables, variables and parameters can be defined as an Enum type, Enum type of element is initialized to Enum constant value specified in the statement, the values can be assigned to include positive and negative, and can not change at run time, for example:

Enum SecurityLevel
IllegalEntry=1
SecurityLevel1=0
SecurityLevel2=1
End Enum

Enum statements can only appear in the module level, define Enum type, you can use it to define variables, parameters or return the type of process, can't use the module name to define Enum type, in the class module Public Enum type is not members of the class; But they have also been written to the type library, defined in the standard module of Enum type is not written in the type library, with the same name of the Public cannot Enum type defined in the standard module, and defined in the class module, because they share the same namespace, if different types of libraries, there are two Enum type the name of the same, but different members, is a reference to this type of variable, which will depend on a reference type library has higher priority,

Cannot use Enum type in With block as the target,

CodePudding user response:

If a variable is defined as the type, the value of the variable can only be 0, one of the three values
  • Related