Author Topic: Difference with a Private Sub / Function  (Read 3724 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Anyone know what the difference between using a sub or function with or without Private before it is used for please? And Is there any benefit with using it?

For example:

Code: [Select]
Sub ( ByVal x As Integer, ByVal y As Integer, ByVal c as Integer )
         'Dummy Sub
End Sub

Or:

Code: [Select]
Private Sub ( ByVal x As Integer, ByVal y As Integer, ByVal c as Integer )
          'Dummy Sub
End Sub


Cheers and many thanks,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2759
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Difference with a Private Sub / Function
« Reply #1 on: May 06, 2006 »
Quote
Syntax

PRIVATE sub/function name


Description

Explicitly sets an individual sub/function to be private (instead of PUBLIC by default). This means the sub/function is only accessible within the module and is hidden to other modules. This means two subs/functions can have the same name, as long as they are private and are in seperate modules.

Subs/functions are private by default if the command OPTION PRIVATE is used, otherwise they are public by default.


If you have coded 2 librarys (*.bi) and if they use same name for one function/sub you can make those functions private for each separated module (.bi file).

Quote
And Is there any benefit with using it?

Maybe, but I never used it until today :(
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Difference with a Private Sub / Function
« Reply #2 on: May 06, 2006 »
So it's like having a local subroutine / function for seperate includes, so it cant be used by other source listings that are shared.

Cheers Rbraz.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won: