Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Attribute Value.VB_UserMemId" not working

Status
Not open for further replies.

JTBorton

Technical User
Jun 9, 2008
345
DE
I am working on a class and want to set the Item property as the default property. I followed the instructions from Pearson's site, and every other site with information about it, and exported the class into a text file. I then inserted "Attribute Value.VB_UserMemId = 0" into the desired property as follows:

Code:
Public Property Get Item(Index As Integer) As emlAttachment
    'HIDDEN CODE - DO NOT EDIT THIS SPACE
    [highlight]Attribute Value.VB_UserMemId = 0[/highlight]
    'END OF HIDDEN CODE
    If Index > Count Then
        '********** TO BE CODED **********
    End If
    Set Item = objAttachments(Index)
End Property

I then saved the file, removed the old class module from my project and imported the new. However, VB seems to be erasing the line I am trying to place into it. The default property does not work, and after exporting the class module back into the text editor I find the following (notice the line has been deleted):

Code:
Public Property Get Item(Index As Integer) As emlAttachment
    'HIDDEN CODE - DO NOT EDIT THIS SPACE
        'END OF HIDDEN CODE
    If Index > Count Then
        '********** TO BE CODED **********
    End If
    Set Item = objAttachments(Index)
End Property

What am I doing wrong?

-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]
 
You need the property name after 'Attribute':
[tt]Attribute Item.VB_UserMemId = 0[/tt]

combo
 
Oh I see. I thought "Value" was part of the command or something. I also had to remove the comment above it. Apparently it only works when placed directly below the procedure heading. Thanks again Combo!

Code:
Public Property Get Item(Index As Integer) As emlAttachment
Attribute Item.VB_UserMemId = 0
    'This is the default property of this class
    If Index > Count Then
        'RAISE ERROR
    End If
    Set Item = objAttachments(Index)
End Property

Hey, while we're on the topic, I'm having a heck of a time trying to understand the default Enum property, UserMemId=-4. I had a very brief discussion about the topic this past last summer (Click here) but an still uncertain.

strongm (MIS) 29 Jul 09 14:48
The word 'enum' is short for two slightly different things

1. enum: a distinct type consisting
of a set of named constants known as the enumerator list
2. enum: a function that enumerates ...

What exactly do you do with a default enum? And what is a function that enumerates?

I found a block of code on another website (Click here) which uses a default enum but I can't figure out what it is for:
Code:
Property Get NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
Attribute NewEnum.VB_MemberFlags = "40"

Set NewEnum = Me_Collection.[_NewEnum]
End Property



-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top