|
-
Oct 16th, 2001, 05:00 AM
#1
Thread Starter
Junior Member
-
Oct 16th, 2001, 08:49 AM
#2
Code:
Public Enum IColors
icMistyRose = &HE1E4FF&
icSlateGray = &H908070&
icDodgerBlue = &HFF901E&
icDeepSkyBlue = &HFFBF00&
icSpringGreen = &H7FFF00&
icForestGreen = &H228B22&
icGoldenrod = &H20A5DA&
icFirebrick = &H2222B2&
End Enum
Property Let Color(Ic as IColors)
End Property
This uses an enum as a property, limits the entries to the items enumerated { icMistRose ... icFireBrick}, and will show up in the type libaray (& object browser).
That what you need?
-
Oct 16th, 2001, 10:08 AM
#3
Thread Starter
Junior Member
Not really working
I've already tried some implementations of an enum in an interface, but it doesn't seem to work in ActiveX DLL's. On the other hand, it does work work with ActiveX EXE's! But I don't want to use A' EXE's!
Greetz,
Bartozz
-
Oct 16th, 2001, 10:19 AM
#4
Please show me how you define the interface, then show me an implementation.
-
Oct 17th, 2001, 01:42 AM
#5
Thread Starter
Junior Member
Some implementation
Here is some implementation (it's an ActiveX DLL):
iClass
-------
Option Explicit
Property Get Interface() As String
End Property
' Filename.
Property Let FileName (nv As String)
End Property
Property Get FileName () As String
End Property
' Name.
Property Let Option (nv As Integer)
End Property
Property Get Option () As Integer
End Property
.
.
.
cClass
--------
Option Explicit
Implements iClass
Private msFileName$
Private miOption%
Property Get iClass_Interface() As String
iClass_Interface = "iClass"
End Property
Private Property Let iClass_FileName(nv As String)
msFileName = nv
End Property
Private Property Get iClass_FileName() As String
iClassFileName = msFileName
End Property
Property Let iClass_Option (nv As Integer)
Select Case nv
Case 0, 1, 2, 3
miOption = nv
Case Else
Err.Raise c__INVALID_VALUE, iClass_Interface, c__INVALID_VALUE_TEXT
End Select
End Property
Property Get iClass_Option () As Integer
iClass_Option = miOption
End Property
.
.
.
Now it's about the Option-thing... The Option property has only 4 options, as shown: 0, 1, 2 and 3. Now I do it with the Select Case thingie, but it has to be arranged with Enumerations! Not only the possible values will be shown explicitly to the developer using my component, so he/she doesn't have to read stacks of paper to figure out which values can be used!
Do you get my idea?
-
Oct 18th, 2001, 05:07 AM
#6
This DOES work in an ActiveX dll...
In the interface definition you have to use the enumeration
' Name.
Property Let Option (nv As enumMyclass)
End Property
Property Get Option () As enumMyClass
End Property
.
.
In the implementation - (another .cls module)
Public enum enumMyClass
enumMyClassRed = 1
enumMyCLassGreen = 2
End enum
Private mMyClass as enumMyClass
Property Let iClass_Option (nv As enumMyCLass)
' you don't need a case statement because you'll always
' get the right range of values
mMyCLass = nv
End Property
Property Get iClass_Option () As enumMyClass
iClass_Option = mMyCLass
End Property
-
Oct 18th, 2001, 05:12 PM
#7
Hyperactive Member
Remember, however, though enumeration suggests a list of possible values, it doesn't restrict the user/developer from assigning values which are not in the Enum List. Consider the following:
VB Code:
Enum Bang
BangOne
BangTwo
End Enum
A property of type Bang will cause VB to suggest BangOne and BangTwo as the possible values which correspond to 0 and 1, however, it is possible to assign values other than these two to the property and VB will not perform any Validation checking, nor it will restrict from any other numeric value.
Enums perfectly work with all type of projects.
Abu Haider
____________________________
100% Data Validation for the MS DataGrid Control. Plus Support for Custom and Foreign Lists, DatePicker and much more...
The DataGridEnhancer
I often point to a place where the problem has been discussed, instead of giving you the code that solves it. This is for good, may be you will understand some day...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|