473,396 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Public vs Shared

Hi

What is the difference between a public and a shared sub?

Thanks

Regards
Nov 21 '05 #1
4 1998
John wrote:
Hi

What is the difference between a public and a shared sub?

Thanks

Regards


You are comparing apples and bananas there.

Public vs. Private
Shared vs. Not Shared

A shared sub is one that can be called without instantiating the class.
For example you can call messagebox.show without creating a messagebox
class. A shared sub must be public to be called.

Chris
Nov 21 '05 #2
"Chris" <no@spam.com> schrieb:
A shared sub must be public to be called.


.... or 'Friend' or 'Protected Friend' -- it depends on which place you are
calling the method from.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:Ox*************@tk2msftngp13.phx.gbl...
: Hi
:
: What is the difference between a public and a shared sub?
:
: Thanks
:
: Regards
A shared sub is one that is not associated with a specific instance of a
class. For example, when you write to the console, you don't have to
create an instance of the 'System.Console' class in order to generate
the desired output.
Ralf

Nov 21 '05 #4
John,

In the documentation about program languages is mostly used Static and
Public.

The first tells something about the way how members in memory are handled
the other about the rights how to use those.

VB has already a keyword Static (Shortly described: A value inside a
procedure that goes not out of scope at the end of a procedure)

In other words Shared is used in VBNet where mostly C derived languages use
Static.

I can understand your confusion, I find sharing not so a nice name, maybe
was the translation. Sharing the memory by all members of an application. In
fact is a Module a kind of Shared (Static) Class.

Public has the normal meanings for Public, which means that a member in a
class can be reached by "EveryBody". For this are extra keywords to limit
this again.

I hope this helps,

Cor
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: May | last post by:
greetings, i came across a function while browsing thru the net. This function is created in a component. what i am curious to know is, is this the correct way to create a function using: Public...
2
by: THY | last post by:
Hi, I am having some problem, I declare few variable in a public module and use them in the web application. But after that I found that the variable declared in public variable =...
3
by: Joe Fallon | last post by:
I have a Shared varibale in a base class and all the Shared methods in the sub-classes use it (and CHANGE it). I thought I was saving myself the "trouble" of Dimming this variable inside each...
10
by: darrel | last post by:
I'm still trying to sort out in my head the differences between public and shared when referring to declaring properties or variables. This is my understanding: shared - akin to a 'global'...
4
by: Chris | last post by:
Hello, I'm just getting started with VB and am new to the group, so please excuse what may seem to be a rudimentary question. I've been writing basic programs and have noticed that the...
5
by: Neil Steventon | last post by:
Hi, I am new to VB.net , well the objects concept anyway and was wondering if there were any good articles / turorials on when and why you would use certain declarations such as Private test...
2
by: Jon Paal | last post by:
In a 2.0 vb code class, I have a private property and a shared public function The property value has already been passed into the class, now I am trying to use a public finction which also needs...
2
by: Darrel | last post by:
I'm working on an app where the ASPX pages aren't precompiled with the class.vb files I'm. This is so people can add their own ASPX pages down the road to the app (the .aspx pages become...
8
by: Al | last post by:
I'd like to create Class Library in VB 2005, which has a property accessible by external programs. I decided to include 1 Class with 1 property in this project. I placed this code in Class:...
9
by: Rudy | last post by:
Hello All! I'm a little confused on Public Class or Modules. Say I have a this on form "A" Public Sub Subtract() Dim Invoice As Decimal Dim Wage As Decimal Static PO As Decimal Invoice =...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.