+ Reply to Thread
Results 1 to 9 of 9

Passing a private variable to another module

Hybrid View

  1. #1
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485
    Are you sure about where each code sample is?

    Are you saying your class exposes click events?


    I thought I had posted a reply, maybe I forgot to submit.

    You can declare a public variable in the class or a private variable with get/let properties.

    In your main code you will need to assign the value to the property before executing the function that uses it other wise the value will be zero
    Cheers
    Andy
    www.andypope.info

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176
    Andy -

    Sorry, you lost me in your comments. I'm not sure what the "get/let" properties are nor do I know where to assign the value. The whole assigning variables and letting other procedures use these variables is somewhat new to me. Realistically, I would really like to declare "j" as a private variable and then pass the value to the function that needs it. I have attached a copy of the spreadsheet so you can see where each code is stored. HTH. Thanks again for your comments.
    Attached Files Attached Files

  3. #3
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    As I said, if you will copy the Public to the top of both the sheet and the Module, it will work. Or, Dim j in the module where it was not defined as Public.

    While you have few rows and J as integer will work, it is generally a good practice to dim variables that reference row numbers as Long.

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

    The attached file has the corrections. The row number "j' is now stored as a public variable "LineNumber" in the class module. Property Let assigns the value and Property Get returns the value.

    Sincerely,
    Leith Ross
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176
    That works now. Thanks for all the help and valuable comments from all.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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