Setting default property of custom collection class


  1. Posts : 26
    Windows 7 Home Premium 64-bit
       #1

    Setting default property of custom collection class


    In VBA, I am trying to set the Item property of a custom collection class, clsStudents, to be the default property. The recommended way of doing this seems to be as follows:
    1. Remove and export the class module
    2. Change it to a txt file.
    3. Add the following line to the Item property using Notepad:
    'Attribute Item.VB_UserMemId = 0' giving:

    Public Property Get Item(strKey As String) As clsStudent
    Attribute Item,VB_UserMemId = 0
    Set Item = mcol(strKey)
    End Property

    4. Import the txt file back into the project.

    The trouble is the addition is highlighted as a syntax error!

    Ken
      My Computer


  2. Posts : 1,158
    Win7 HP (x64)/Win7 Ultimate (x64)
       #2

    Ken9251 said:
    In VBA, I am trying to set the Item property of a custom collection class, clsStudents, to be the default property. The recommended way of doing this seems to be as follows:
    1. Remove and export the class module
    2. Change it to a txt file.
    3. Add the following line to the Item property using Notepad:
    'Attribute Item.VB_UserMemId = 0' giving:

    Public Property Get Item(strKey As String) As clsStudent
    Attribute Item,VB_UserMemId = 0
    Set Item = mcol(strKey)
    End Property

    4. Import the txt file back into the project.

    The trouble is the addition is highlighted as a syntax error!

    Ken

    Hi

    Would the .(dot)and ,(comma) have anything to do with it?

    Regards
      My Computer


  3. Posts : 26
    Windows 7 Home Premium 64-bit
    Thread Starter
       #3

    Thanks Lomai

    No, I transcribed it incorrectly, but it was a dot in the code. I have, however, found the answer. I had added a comment against the Attribute line and by removing this it has worked OK. I hadn't realised that the line does not display in the editor so it was pointless anyway.

    I suppose the moral is to cut and paste from the code to the message. If I had done so the dot would have shown correctly and the added comment would have been displayed to enable the fault to be diagnosed.

    Thaks again
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:14.
Find Us