I'm trying to find on MSDN, or someplace, that speaks to variables being
public or private by default. Anyone know where? Thanks. 11 5634
By default they are private. You can see the icons in the ClassView window.
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster: http://www.mztools.com
"prefersgolfing " <pr************ @hotmail.com> escribió en el mensaje
news:uq******** ********@TK2MSF TNGP12.phx.gbl. .. I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
I'm not sure that's exactly accurate. In this example
Module Module1
Dim x As String
Sub Main()
x = "This is a string"
Debug.WriteLine (x)
End Sub
End Module
The variable is private to the module BUT public within the module.
I believe it depends more on where the variable is declared.
Joe
--
"Carlos J. Quintero [VB MVP]" <ca*****@NOSPAM sogecable.com> wrote in message
news:ee******** ******@TK2MSFTN GP10.phx.gbl... By default they are private. You can see the icons in the ClassView window. --
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio You can code, design and document much faster: http://www.mztools.com
"prefersgolfing " <pr************ @hotmail.com> escribió en el mensaje news:uq******** ********@TK2MSF TNGP12.phx.gbl. .. I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
Hi all,
"If the Dim statement is used (in Visual Basic .NET) or no access modifier
is used (in Visual C#), the variable is considered private in Visual C# and
Visual Basic .NET classes, Public in Visual Basic .NET structures, and
private in Visual C# structures. Methods do not require an access modifier.
If no access modifier is specified, the method is Private by default if in a
class or structure in C#, and Public if in a class or structure in Visual
Basic .NET."
--- MCAD/MCSD Training Kit Windows Apps. Exam 70-306.
Joe wrote : The variable is private to the module BUT public within the module.
Hi Joe,
I think you are not entirely right. There is no such thing as "public within
the module". The definition of a private variable is one that is not visible
*outside* of the type to which it belongs (Class or struct). "Private" is
the most you can limit the access level, and even all Private variables can
be freely accessed within the class they are declared.
I believe it depends more on where the variable is declared.
Yes, you are right about that. As above, variables in VB.NET structures are
by default Public.
"prefersgolfing " <pr************ @hotmail.com> wrote in message
news:uq******** ******@TK2MSFTN GP12.phx.gbl... I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
Actually, no I'm right. You're only pointing out a semantical issue.
Since we're in the VB newsgroup, the posts about other languages don't
apply.
"Cerebrus99 " <zo*****@sify.c om> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. Hi all,
"If the Dim statement is used (in Visual Basic .NET) or no access modifier is used (in Visual C#), the variable is considered private in Visual C# and Visual Basic .NET classes, Public in Visual Basic .NET structures, and private in Visual C# structures. Methods do not require an access modifier. If no access modifier is specified, the method is Private by default if in a class or structure in C#, and Public if in a class or structure in Visual Basic .NET."
--- MCAD/MCSD Training Kit Windows Apps. Exam 70-306.
Joe wrote : The variable is private to the module BUT public within the module.
Hi Joe,
I think you are not entirely right. There is no such thing as "public within the module". The definition of a private variable is one that is not visible *outside* of the type to which it belongs (Class or struct). "Private" is the most you can limit the access level, and even all Private variables can be freely accessed within the class they are declared.
I believe it depends more on where the variable is declared. Yes, you are right about that. As above, variables in VB.NET structures are by default Public.
"prefersgolfing " <pr************ @hotmail.com> wrote in message news:uq******** ******@TK2MSFTN GP12.phx.gbl... I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
Hello, Golfer,
Try: http://msdn.microsoft.com/library/de...essibility.asp
Or search help for "scope".
But, the fact there is discussion about this means many people are in
doubt about it. May I humbly suggest that you always declare your names
explicitly.
Cheers,
Randy
prefersgolfing wrote: I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
Hi Joe,
What are you talking about here? The scope of a class/module variable refers
to its visibility outside the class/module where they are declared. Of
course that a class or module-level variable is reachable within the
class/module, how could it be otherwise?
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster: http://www.mztools.com
"Joe Sutphin" <jo********@ear thlink.net> escribió en el mensaje
news:OR******** ******@TK2MSFTN GP14.phx.gbl... I'm not sure that's exactly accurate. In this example
Module Module1 Dim x As String Sub Main() x = "This is a string" Debug.WriteLine (x) End Sub End Module
The variable is private to the module BUT public within the module.
I believe it depends more on where the variable is declared.
Joe --
Joe, The variable is private to the module BUT public within the module. I believe it depends more on where the variable is declared.
I don't see what you mean, a variable is default private it nothing is add
to it.
We can forget the DIM keyword because that adds nothing (and therefore the
same as not used in C#).
A value delclared inside a method can only be private to that method. A
value on Class level can have other access rights. (See for that the message
from Randy).
A module is nothing more than a Class which has all his members shared
global to the application (main class).
Cor
Joe,
See my other answer to you,
Cor
For all intents and purposes DIM and Private are equal.
There are three levels of scope. All variables declared within a procedure
are private.
Variables declared within a module are private to that module using either
Dim or Private.
Variables declared within a module as Public are accessible to any procedure
inside or outside of that module.
Again, my original statement stands, it depends on where you declare the
variable. Not declaring it properly is just wrong!
Joe
--
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. Joe,
The variable is private to the module BUT public within the module. I believe it depends more on where the variable is declared. I don't see what you mean, a variable is default private it nothing is add to it. We can forget the DIM keyword because that adds nothing (and therefore the same as not used in C#).
A value delclared inside a method can only be private to that method. A value on Class level can have other access rights. (See for that the message from Randy).
A module is nothing more than a Class which has all his members shared global to the application (main class).
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ng Hun Yang |
last post by:
I have a class that has a default constructor that initializes the
class's variables. Now I want to add a new constructor to skip the
initialization.
My attempt:
class Integer {
public:
class NoInit { }; // newly added
public:
|
by: Phil Certain |
last post by:
Hi
I'm building a site that has publicly available pages and password
protected pages. Publicly available pages reside in:
/public
and password protected pages reside in:
/private
|
by: Andrew J. Marshall |
last post by:
I want to create a class that must receive a parameter when instantiated.
In other words, I do not want it to have a "Public Sub New()".
1) Does VB.NET create a default public constructor if I do not declare one?
2) I've read that I can have a "Private Sub New()" which should take care of
my needs. Comments?
Thanks,
Andrew
|
by: Marty McFly |
last post by:
Hello,
I have a control class that inherits from System.Web.UI.WebControls.Button.
When I drag this control from the "My User Controls" tab in the toolbox onto
the form, I want it to reflect the following default properties: Height =
32px, Width = 144px.
I declare the Width property in my control as...
\\\
|
by: Wonder |
last post by:
How can I create or use the msgobx to show a message without a default
button. The user has explicity to click on the button, so the msgbox closes
it.
Thanks,
| |
by: Tony Johansson |
last post by:
Hello!!
If you write private class Test {} you have a private class
If you write public class Test {} you have a public class
If you write protected class Test {} you have a protected class
If you write internal class Test {} you have a internal class
Now to my question
If you just write class Test {}
what access is it then on the class Test meaning what is the default access.
|
by: Anil Gupte |
last post by:
I wrote my Windows Service first as a regular Windows Exe because it is
easier to debug. In that I used
AppDir = Application.ExecutablePath.Substring(0,
Application.ExecutablePath.LastIndexOf("\")) ' Where this application
Excutable sits
Now, when I am converting it to a Service, what path can I use? Or can I
specify a path in the service to always use as a data path? I would prefer
the former because I do not know the layout of...
|
by: Jeff |
last post by:
Hi
I'm trying to achieve a scenario where I have c# files that are compiled
dynamically, the assemblies are then loaded in a different AppDomain, I call
a simple method from the object, and then unload the AppDomain to release
the lock on the assemly files (so to I can compile the code again if it has
been modified). However, I've encountered a problem, whereby the assembly is
also loaded in the default AppDomain!
I have a few classes...
|
by: * Tong * |
last post by:
Hi,
I couldn't figure out the answer myself about the default constructor --
does C++ create it by default? If yes, under what circumstances?
Actually, I've found out the partial answer myself via trying the
following code:
-----------------------------------------
#include <string>
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |