Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using an enum for a property in a class module

Posted on 2006-11-09
10
Medium Priority
?
755 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

715 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