Public vs. Private
A when something is public that means that something is available outside and inside the class. A Private something is only available inside a class. Nothing more, nothing less.
Many people still ask question about the difference about a private or a public. When a use the word something, this take effect to variable, object, class, sub function, thread …
This is also true for a Module. So a private member in a Module will only be available inside the Module and a public will be available inside and outside that Module.
Take a look that the sample code. I use a module to put my private and my public integer.
Module Module1 Public iNumber As Integer Private iCount As Integer End Module |
When you type Module1, Visual Studio will try to suggest choice. You will see the public Integer iNumber and not the private iCount .
When you try to use the private member, well …. You will get an error.
Please note, private and public is a concept and is true for C++, Java Visual Basic, C# and may other stuff. There is of course one exception: See Electrical Expert™ from IGE-XAO.
In their VBA (Visual Basic for Application), their private or public don’t work. In Fact everything is public witch is a flood and is a bug. That bug it exist since See Electrical Expert™ 2004, 2005, v3r5, v3r6, v3r7 and the new V4. For the last know issue of the V4, is true and I believe is still true but can’t confirm it today. Last time I checked, it was on spring 2012 and I don’t think is fixed. The matter the fact, we might never know, the VBA is removed from their web site so I guest the VBA is no longer available.
Anyway, there are not a lot of people around the world who program macros in See Electrical Expert™ or cares.
The concept of private and public works fine in MS-Excel, MS-Word, MS-Outlook, Autodesk products such as AutoCAD™, NavisWorks™ …
References :
Private in MSDN : Private (Visual Basic)
Public in MSDN: Public (Visual Basic)
My web site : Check Technologies
Download Sample Project : SamplePrivatePublic.zip
0 Response to "Public vs. Private"
Posting Komentar