Solved

Using an enum for a property in a class module

Posted on 2006-11-09
10
752 Views
Last Modified: 2010-09-08
I have written a class module to implement the Common Dialogue functionality using API calls without using the CommonDialog control, because of problems with versions on different machines

I am wanting to use an enum to prompt for acceptable values for a property at design time, but it does not work, where it does work in a normal module - for example:

Public enum sType
  First =1
  Second =2
  Third =3
end enum

Public Function GetType(sItem as sType) as integer
  GetType=sItem
end function

When you start to type a call to the function, as you type the ( a list of acceptable values (First, Second, Third)

If I do the same in a Property Let function in a class module, it doesn't work in the same way - what can I do so that it will e.g

clsCommonDialog - module definition

Public Enum cdlFlags
    cdlOFNReadOnly = &H1
    cdlOFNOVERWRITEPROMPT = &H2
    cdlOFNHIDEREADONLY = &H4
    cdlOFNNOCHANGEDIR = &H8
    cdlOFNSHOWHELP = &H10
    cdlOFNNOVALIDATE = &H100
    cdlOFNALLOWMULTISELECT = &H200
    cdlOFNEXTENSIONDIFFERENT = &H400
    cdlOFNPATHMUSTEXIST = &H800
    cdlOFNFILEMUSTEXIST = &H1000
    cdlOFNCREATEPROMPT = &H2000
    cdlOFNSHAREAWARE = &H4000
    cdlOFNNOREADONLYRETURN = &H8000
    cdlOFNNOTESTFILECREATE = &H10000
    cdlOFNNONETWORKBUTTON = &H20000
    cdlOFNNOLONGNAMES = &H40000
    cdlOFNEXPLORER = &H80000
    cdlOFNNODEREFERENCELINKS = &H100000
    cdlOFNLONGNAMES = &H200000
End Enum


Public Property Let Flags(vNewValue As cdlFlags)
' Code Header inserted by VBA Code Commenter and Error Handler Add-In
'=============================================================
' clsCommonDialog.flags
'-------------------------------------------------------------
'assign object's Flags property

    On Error GoTo HandleErr

    lFlags = vNewValue

ExitHere:
    Exit Property

    ' Error handling block added by VBA Code Commenter and Error Handler Add-In. DO NOT EDIT this block of code.
    ' Automatic error handler last updated at 24 May 2005 10:54:39
HandleErr:
    Select Case Err.Number
    Case Else
        MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "clsCommonDialog.flags"
    End Select
    ' End Error handling block.
End Property



=======================

dim cdl as New clsCommonDialog


With cdl
  .Flags = ..........................  Would like to be prompted with the list of options here when typing the code
end with

0
Comment
Question by:cquinn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17905401
Umm it should be already.
Everything you have in place seems to be as it should.

The Enum is public...
The type is passed...

Have you tried (I know - the inevitable) compact, repair, decomp.
Checked there are no naming conflicts - either with built in objects - or other ones you have?

I'll keep looking at it to see if I notice anything.. :-S
0
 
LVL 15

Author Comment

by:cquinn
ID: 17905698
I have tried all of that, but no joy

0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17905878
Have you tried it in a new mdb - with nothing but your class imported.
Then a new module - instantiating your class, and looking for the intellisense.

Perhaps trying different property names?  (Other than Flags?)
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 15

Author Comment

by:cquinn
ID: 17906711
I've imported the class into a new db and created a new module, no joy

I've renamed the property to FileFlags - again no joy - still no intellisense
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17906936
OK, hang on - I'll try it with your actual example.
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17906950
Nope - works perfectly.
Very odd.
0
 
LVL 15

Author Comment

by:cquinn
ID: 17913450
I have uploaded a simple database with my class module and a single form using it here:

The flags property is shown by intellisense when typing, but the enum values are not - I have also noticed that if I type a enum item in lower case (eg cdlofnreadonly when it is typed as cdlOFNReadOnly in the class module), it changes to lowercase in the class module!  Very strange!

https://filedb.experts-exchange.com/incoming/ee-stuff/1343-CDL.zip

0
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 125 total points
ID: 17913542
Hi.

I think the problem is in a slight inconsistency.
You require a variable of type cdlFlags passed to the Flags property Let call.
But in your property Get you've declared it as a Long.
If you change that to be cdlFlags too - then I reckon you'll get your intellisense back.

:-)
0
 
LVL 15

Author Comment

by:cquinn
ID: 17913684
I changed the type in the Property Get and shazzam!  Intellisense works!  

Many thanks

Chris
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17913688
Most welcome.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question