What is the Difference between Global and Public, Dim and Private variables? in Visual Basic 6.0. Because I am always using Public and Dim but using Global and Private is doing the same thing, is there any differences between these types of declaration scopes???????
Example:
What is the difference:
' In bas Module
Option Explicit
Global gblmyVar1 as Long ' Declared as Global
Public pblmyVar1 as Long ' Declared as Public
' In Form Module
Private prvRecSet as New ADODB.Recordset ' Declared as Private
Dim dimRecSet as New ADODB.Recordset ' Decalred as Dim
Please help, thanks in advance.
Jan 20 '07
11 19756
About the Option Private Module, I just figured it out that If VB6 implement this kind of Option then I think that is the reason why there is a GLOBAL Statement, So if you will try to disable the Option Private module then Global statement is in effect and you can access your variables with GLOBAL statement in different types of your projects.
Thanks guys I appreciate all your help and Ideas, but if you think this is not the answer you can suggest another, please don't hesitate to post your answers...
To be honest, I'm a bit lost.
I used to use Global in VB5 and earlier, but have since converted over to using Public. I still have code which says Global, because it was written in an earlier version. Both seem to work just fine, and I don't think I've heard of Option Private Module before.
The problem is, I've had very little experience with multiple projects. The only time I've worked with more than one project is when I'm creating a user control, in which case the "main" project is generally little more than a form with an instance of the control on it for testing. And I've only done this on rare occasions, as I can never find the time to play with this stuff.
Killer42 : I used to use Global in VB5 and earlier, but have since converted over to using Public. I still have code which says Global, because it was written in an earlier version. Both seem to work just fine, and I don't think I've heard of Option Private Module before. - there are no more Global in after VB6.
- if your program is small and works well, you are right that public-private-global do the same thing. is just the range those variable will have.
here is a link. it summarize the use of global variable in VB.NET. works almost the same thant VB6. VB.NET removed the Global keyword and is replaced by a shared variable inside a class. Global Variables in Visual Basic .NET ; Everything you need to know about Global Variable for VB.NET in this single Post.
there is a simple Private-Public article i made. might give a hand: Public vs. Private Sign in to post your reply or Sign up for a free account.
Similar topics |
by: gabor |
last post by:
hi,
as far as i know in python there aren't any private (i mean not accessible
from the outside of the object) methods/fields.
why?
in java/c++ i can make a method private, this way unaccessible for the outside
world. i think it helps a lot to make for example a library more robust.
|
by: Janaka |
last post by:
I'm having a discussion with my colleagues here on good programming
standards. One thing we haven't agreed on is the use of properties in
classes vs using member variables. Now everyone knows that it is useful to
use a property when it has to do some further action on the data such as
private double salesAvg;
public double SalesAverage
{
set {
salesAvg = value / salesTotal;
}
|
by: John C Kirk |
last post by:
One odd thing I've come across - if you declare a private variable in
a class, it is exposed to other instances of that same class.
To replicate this behaviour, create a class like this:
Public Class Class1
Private mintID As Integer = 0
Public Sub New(ByVal pintID As Integer)
|
by: Steve |
last post by:
I generate C# webservices proxy code from WSDL file, it turns out the
classes
generated have public member variables and no getter/setter methods as
follows,
and I am able to get data when running the client.
public class MyFeeResponse {
|
by: Rob Long |
last post by:
Hi there
Is there any way to access private variables directly from within a
priviliged function? I have a situation where the priviliged function's
execution context contains variables of the same name as the parent
context, but I want direct access to the parent context's variable.
E.g. I would like to be able to do this...
function Point()
| |
by: Sky |
last post by:
Hello:
I'm trying to make sense of snk files, when to use, under what conditions to
regenerate new ones,...can someone take a look if these statemes make sense?
And then the final questions at the end that they first statements bring up
in my mind...
a) Because two developers, unbeknownst to each other, can end up releaseing
different dll's with the same name, one should sign an assembly with a unique
tag. right?
|
by: t f |
last post by:
Hi
I have a class with a bunch of private variables in, is there an easy
way to make these have public properties without having to type it all in?
e.g.
public class Fu
{
private float fBar;
|
by: Jon |
last post by:
Hello all,
I recently posted a question about a tool that would create the public
member variables for a selected set of private member variables - when
there's 10 - 15 privates, it can be very tedious!. I found a number of
options, but all a little costly, so I developed my own.
For example,
if your code has the below private members:
|
by: PragueExpat |
last post by:
I (think) that I've come up with a pattern that I haven't seen in any
publications so far and I would like some feedback. Basically, I was
looking for a way to inherit private functions and I came up with
this:
//base private object constructor
function priv(){
this.a = 1;
this.b = 2;
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |