• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual Basic Customization

    Reply
    *Adesu

    What different Sub, Public, Private and Function

    61 Views, 4 Replies
    07-03-2008 06:06 PM
    I still confuse to adopted that code with added "sub" "public" "private" etc
    , would you please to tell me what diffrent function.

    sub test()
    bla..
    bla..
    end sub
    '--------------------
    public test()
    bla..
    bla..
    end public
    '------------------
    private test()
    bla..
    bla..
    end private
    '--------------
    function test()
    bla..
    bla..
    end function
    '---------------
    public sub test()
    bla..
    bla..
    end public
    Please use plain text.
    Distinguished Contributor
    cadger
    Posts: 366
    Registered: ‎03-28-2007

    Re: What different Sub, Public, Private and Function

    07-05-2008 07:59 AM in reply to: *Adesu
    highlight 'private' in vbaide.

    public lets your subroutine or function be available for use by other modules

    private 'Indicates that the Sub procedure is accessible only to other procedures in the module where it is declared.'

    etc
    Please use plain text.
    *Adesu

    Re: What different Sub, Public, Private and Function

    07-06-2008 06:15 PM in reply to: *Adesu
    thanks for you answerd, i would check again in help file.

    wrote in message news:5974101@discussion.autodesk.com...
    highlight 'private' in vbaide.

    public lets your subroutine or function be available for use by other
    modules

    private 'Indicates that the Sub procedure is accessible only to other
    procedures in the module where it is declared.'

    etc
    Please use plain text.
    Active Contributor
    Posts: 48
    Registered: ‎05-16-2006

    Re: What different Sub, Public, Private and Function

    07-07-2008 10:49 PM in reply to: *Adesu
    Your question can be divided in following two parts
    1. difference between sub and function
    2. difference between private and public

    Sub procedures doesn't return a value while by using functions you can get the returned value e.g.

    Public function XX(byval YY) as string
    End function

    Private functions or sub can be used within a single module where they are defined while public procedures can be call from anywhere within the project.

    Hope I make the thing clear to you.

    Kaushal
    Please use plain text.
    *Adesu

    Re: What different Sub, Public, Private and Function

    07-07-2008 11:51 PM in reply to: *Adesu
    it's good info, I got it.
    thanks.

    wrote in message news:5975553@discussion.autodesk.com...
    Your question can be divided in following two parts
    1. difference between sub and function
    2. difference between private and public

    Sub procedures doesn't return a value while by using functions you can get
    the returned value e.g.

    Public function XX(byval YY) as string
    End function

    Private functions or sub can be used within a single module where they are
    defined while public procedures can be call from anywhere within the
    project.

    Hope I make the thing clear to you.

    Kaushal
    Please use plain text.