+ Reply to Thread
Results 1 to 3 of 3

just new: trying to get/set property of class raises compile error expected: identifier or

  1. #1
    Registered User
    Join Date
    12-15-2018
    Location
    america
    MS-Off Ver
    365
    Posts
    1

    just new: trying to get/set property of class raises compile error expected: identifier or

    I just started testing the waters with VBA in excel and I'm having trouble with a very basic custom class. The code worked when the class property was public and I could access it without get/set functions. However, when I switched to a private class property and added the get/set functions to access the private property I get this error:
    Compile Error: Expected: identifier or bracketed expression

    This is the class module:
    Please Login or Register  to view this content.
    As soon as I type the period after prevEvent and try to select the property from the menu that pops up I get the error. What am I doing wrong? I am following every tutorial I can find on this basic issue.

    Thanks in advance.
    Last edited by Leith Ross; 12-15-2018 at 04:19 PM. Reason: Added Code Tags

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,198

    Re: just new: trying to get/set property of class raises compile error expected: identifie

    Your properties aren’t public and your get wont return anything.

    Also, please add code tags when posting code:
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 6)

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: just new: trying to get/set property of class raises compile error expected: identifie

    Hello himyburneraccount,

    Welcome to the forum!

    The first thing I see is your property Get does not match your property Let statement. You don't need to use the Private keyword. All variables declared inside a Class are private to the Class module. The code should be...

    Please Login or Register  to view this content.
    Next, the "New"keyword will instantiate a new Class object when it is executed. Try this code to assign the property a value and then display the value in a message box.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Can't Assign to Read-Only Property; Compile Error on Assigning Property to Class.
    By Dal123 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-15-2018, 08:09 AM
  2. [SOLVED] Getting compile error 1004 unable to set the hidden property of range class
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2015, 10:21 AM
  3. compile error: expected identifier
    By kamelkid2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-21-2012, 03:07 PM
  4. Compile Error: Expected End Sub
    By Dcauth in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2011, 01:56 PM
  5. compile error: Expected: = ...Why?
    By cesw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2005, 08:05 PM
  6. Compile error: Expected Sub, Function, or Property
    By Cloudfall in forum Excel General
    Replies: 3
    Last Post: 08-30-2005, 01:05 AM
  7. [SOLVED] Compile Error: Expected End Property
    By George J in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2005, 11:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1