Results 1 to 7 of 7

Thread: In a class module, what is a 'friend' property (as opposed to public/private)?

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    In a class module, what is a 'friend' property (as opposed to public/private)?

    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    By specifying another class as "friend" you allow that friend to call the functions and variables of your class.

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    The Friend statement only allows YOUR program / project to call the procedure.

    I'll take 2 examples here...
    Scenario 1 - I create a Public function "Func1" in a class module, then turn this into an ActiveX Dll for my project to use. I then install this program fully completed onto your pc.

    Since I have made this "Func1" public, there's nothing to stop you adding the dll reference into vb, and calling that function.

    Scenario 2 - I create the same function, but declare it with the Friend statement then add the class module inside my project rather than creating a dll separatly. This now means my project can call the code, and any other developer who wants to try & pinch it for use with their project can go & @*%# themselves !!!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Thanks for the clear explanations.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  5. #5
    Hyperactive Member FATBOYPEE's Avatar
    Join Date
    May 2001
    Location
    Charleville (Ireland) Still. ANYONE GOT A JOB I CAN HAVE ? GIZA JOB. I CAN DO THAT....
    Posts
    463
    Originally posted by alex_read


    It's about time I had a good old argument, I'll disagree with that one fatboy, I would say it's accessible from anywhere as long as it's in your project (see attached)
    Agree, misleadi the jury m'lud.... my interpretation moves to scope of implementation...

    Dont disagree with quoting MSDN tho, it often makes things clearer....

    Best Bar.....

  6. #6
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    No harm done, to be honest, that sample was the first time I've used it myself anyways !!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  7. #7
    Hyperactive Member FATBOYPEE's Avatar
    Join Date
    May 2001
    Location
    Charleville (Ireland) Still. ANYONE GOT A JOB I CAN HAVE ? GIZA JOB. I CAN DO THAT....
    Posts
    463
    Originally posted by alex_read
    No harm done, to be honest, that sample was the first time I've used it myself anyways !!
    Not that easy 4 me to get off the hook ! I use friend functions alot but never reference them in the same project....ah still....

    interesting thought though, I recall someone telling me you can set a class member as hidden somewhere but cant remember how....any ideas ?

    Best Bar.....

Posting Permissions

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



Click Here to Expand Forum to Full Width