Results 1 to 4 of 4

Thread: [RESOLVED] Friend function

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2006
    Location
    Chennai, India
    Posts
    87

    Resolved [RESOLVED] Friend function

    What is the use of friend function in VB 6.0

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Friend function

    Quote Originally Posted by balajikandaswamy
    What is the use of friend function in VB 6.0
    I never used friend function in the vb but for vb.net you
    Look Here

  3. #3
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Friend function

    If you have MSDN help installed you can type friend in your project, highlight it, press F1...for this:

    Modifies the definition of aprocedure in a form module orclass module to make the procedure callable from modules that are outside theclass, but part of theproject within which the class is defined. Friend procedures cannot be used in standard modules.

    Syntax

    [Private | Friend | Public] [Static] [Sub | Function | Property] procedurename

    The required procedurename is the name of the procedure to be made visible throughout the project, but not visible to controllers of the class.

    Remarks

    Public procedures in a class can be called from anywhere, even by controllers of instances of the class. Declaring a procedure Private prevents controllers of the object from calling the procedure, but also prevents the procedure from being called from within the project in which the class itself is defined. Friend makes the procedure visible throughout the project, but not to a controller of an instance of the object. Friend can appear only in form modules and class modules, and can only modify procedure names, notvariables or types. Procedures in a class can access the Friend procedures of all other classes in a project. Friend procedures don't appear in thetype library of their class. A Friend procedure can't be late bound.


    When placed in a class module, the following code makes the member variable dblBalance accessible to all users of the class within the project. Any user of the class can get the value; only code within the project can assign a value to that variable.

    VB Code:
    1. Private dblBalance As Double
    2.  
    3. Public Property Get Balance() As Double
    4.     Balance = dblBalance
    5. End Property
    6.  
    7. Friend Property Let Balance(dblNewBalance As Double)
    8.     dblBalance = dblNewBalance
    9. End Property

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2006
    Location
    Chennai, India
    Posts
    87

    Re: Friend function

    Thanks tysonlprice

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