Saturday, December 26, 2009

ENUM

ENUM

Syntax
[ Private | Public ] Enum EnumName
name1 [ = value1 ]
name2 [ = value2 ]
.
.
.
nameN [ = valueN ]
End Enum
Usage
The Enum statement defines a list of constants. Private means that the constants will be local to the module in which they are declared. Public means that you can reference the constants from anywhere in the program. If neither Public nor Private is specified, then Public will be assumed.
Arguments
EnumName--a valid Visual Basic identifier that describes the collection of constants.
name1--a valid Visual Basic identifier that is associated with a particular constant.
value1--a Long value that can be any expression including using other constants and enum values. If this value is omitted, it will default to zero.
name2--a valid Visual Basic identifier that is associated with a particular constant.
value2--a Long value that can be any expression including using other constants and enum values. If this value is omitted, it will default to one or one more than the previous constant.
nameN--a valid Visual Basic identifier that is associated with a particular constant.
valueN--a Long value that can be any expression including using other constants and enum values. If this value is omitted, it will default to one more than the previous constant.
Examples
Public Enum MyBits
bit1 = 2
bit2 = 4
Bit3 = 8
bit4 = 16
Bit5 = 32
Bit6 = 64
Bit7 = 128
End Enum
Private Sub Command1_Click()
MsgBox "The value of bit 1 in B is " & Format(Asc("B") Mod bit1)
End Sub
This program uses enumerated set of values MyBits to examine the lowest order bit of the character B. Since the ASCII value of B is 01000010 the answer will be zero.
See Also:
Const (statement), Dim (statement)


WITH STATEMENT
Syntax
With object
[ list of statements ]
End With
Usage
The With statement is used to qualify a single object or user-defined type. Properties of the qualified object may omit the object name and begin with a period (".").
Arguments
object--the name of the object to be qualified.
Examples
Private Sub Command1_Click()
With Text1
.Text = "Testing the with statement."
.Font.Size = 36
.Font.Bold = True
End With
End Sub
This routine uses a With statement to simplify assigning values to Text1 text box object.
See Also:
Object (data type)

No comments:

Post a Comment