in the old VB, you can use global variables to hold commonly use data. i'll
like to pass a variables selected by user in the combobox, how do you hold
this variable for other object to use. does anyone have an example? 11 8833
You can use a static property.
For example:
public class Global {
private Global() {}
public static string UserName;
}
Hello dotnetnoob,
You can create a module, and declare Global variables in the module just
the way you did in the old VB. Classes are not actually meant as holders
of global variables.
Just add a module to your project and declare a variable like this
Public myVariable as Integer
Regards
Cyril Gupta
You can do anything with a little bit of 'magination.
I have been programming so long, that my brain is now soft-ware. http://www.cyrilgupta.com/blog
in the old VB, you can use global variables to hold commonly use data.
i'll like to pass a variables selected by user in the combobox, how do
you hold this variable for other object to use. does anyone have an
example?
thank all for reply.
how do you pass commonly use variable in C# then?
so i can add a module in my program to hold the data selected by user in
combobox and use it for other object to access, am i correct?
"Cyril Gupta" wrote:
Hello dotnetnoob,
You can create a module, and declare Global variables in the module just
the way you did in the old VB. Classes are not actually meant as holders
of global variables.
Just add a module to your project and declare a variable like this
Public myVariable as Integer
Regards
Cyril Gupta
You can do anything with a little bit of 'magination.
I have been programming so long, that my brain is now soft-ware. http://www.cyrilgupta.com/blog
in the old VB, you can use global variables to hold commonly use data.
i'll like to pass a variables selected by user in the combobox, how do
you hold this variable for other object to use. does anyone have an
example?
Steven Nagy wrote:
You can use a static property.
For example:
public class Global {
private Global() {}
public static string UserName;
}
Sorry I thought I was in the C# group.
Here's the VB code:
public class Global
public shared string UserName
end class
Hi there,
Sorry but that is just not true. You can object orientate anything. In
fact I'd rather do that than use modules any day.
In my honest opinion a shared class is much better than a module,
-------------------------
Public Class GlobalObjects
'//Hide the constructor as it is not needed
Private Sub New()
End Sub
Public Shared gBlnDebugMode As Boolean
End Class
-------------------------
Nick.
"Cyril Gupta" <cy***@nospam.comwrote in message
news:a9*************************@msnews.microsoft. com...
Hello dotnetnoob,
You can create a module, and declare Global variables in the module just
the way you did in the old VB. Classes are not actually meant as holders
of global variables.
Just add a module to your project and declare a variable like this
Public myVariable as Integer
Regards
Cyril Gupta
You can do anything with a little bit of 'magination.
I have been programming so long, that my brain is now soft-ware. http://www.cyrilgupta.com/blog
>in the old VB, you can use global variables to hold commonly use data. i'll like to pass a variables selected by user in the combobox, how do you hold this variable for other object to use. does anyone have an example?
Just as an addition: Depending on how you plan to use the variable, you
may want to consider wrapping the variable in a public shared property.
This comes in handy for things like validating entries, error trapping,
etc...
Thanks,
Seth Rowe
NickP wrote:
Hi there,
Sorry but that is just not true. You can object orientate anything. In
fact I'd rather do that than use modules any day.
In my honest opinion a shared class is much better than a module,
-------------------------
Public Class GlobalObjects
'//Hide the constructor as it is not needed
Private Sub New()
End Sub
Public Shared gBlnDebugMode As Boolean
End Class
-------------------------
Nick.
"Cyril Gupta" <cy***@nospam.comwrote in message
news:a9*************************@msnews.microsoft. com...
Hello dotnetnoob,
You can create a module, and declare Global variables in the module just
the way you did in the old VB. Classes are not actually meant as holders
of global variables.
Just add a module to your project and declare a variable like this
Public myVariable as Integer
Regards
Cyril Gupta
You can do anything with a little bit of 'magination.
I have been programming so long, that my brain is now soft-ware. http://www.cyrilgupta.com/blog
in the old VB, you can use global variables to hold commonly use data.
i'll like to pass a variables selected by user in the combobox, how do
you hold this variable for other object to use. does anyone have an
example?
Exactly, much more friendly than a simple module...
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
Just as an addition: Depending on how you plan to use the variable, you
may want to consider wrapping the variable in a public shared property.
This comes in handy for things like validating entries, error trapping,
etc...
Thanks,
Seth Rowe
NickP wrote:
>Hi there,
Sorry but that is just not true. You can object orientate anything. In fact I'd rather do that than use modules any day.
In my honest opinion a shared class is much better than a module,
-------------------------
Public Class GlobalObjects
'//Hide the constructor as it is not needed Private Sub New() End Sub
Public Shared gBlnDebugMode As Boolean
End Class
-------------------------
Nick.
"Cyril Gupta" <cy***@nospam.comwrote in message news:a9*************************@msnews.microsoft .com...
Hello dotnetnoob,
You can create a module, and declare Global variables in the module
just
the way you did in the old VB. Classes are not actually meant as
holders
of global variables.
Just add a module to your project and declare a variable like this
Public myVariable as Integer
Regards
Cyril Gupta
You can do anything with a little bit of 'magination.
I have been programming so long, that my brain is now soft-ware. http://www.cyrilgupta.com/blog
in the old VB, you can use global variables to hold commonly use data. i'll like to pass a variables selected by user in the combobox, how do you hold this variable for other object to use. does anyone have an example?
I've always hated modules personally... no real scope and no
encapsulation.
Funny, I always thought modules were in fact Classes with all the variables
and procedures Shared!
Can you explain the difference?
--
Dennis in Houston
"Steven Nagy" wrote:
I've always hated modules personally... no real scope and no
encapsulation.
While I could get out the old soapbox, I think I'll just advise readers
to search the ng for this heavily debated topic! But if you don't want
to search too much then the main differences I know of are that modules
are given an automatic project wide import statement (kinda), and can't
be instantiated.
Thanks,
Seth Rowe
Dennis wrote:
Funny, I always thought modules were in fact Classes with all the variables
and procedures Shared!
Can you explain the difference?
--
Dennis in Houston
"Steven Nagy" wrote:
I've always hated modules personally... no real scope and no
encapsulation.
I'm not sure how they run under the hood. Chances are that they are
just a class.
the main differences I know of are that modules
are given an automatic project wide import statement (kinda),
... which means that you can't control scope. So its better to use a
class and implement it in a way that scope is important. Modules are
often misused. People stick everything in them. I've seen forms
declared in there, database connections, etc.
Implement a class instead. Control access as necessary. Implement a
singleton where relevant. There's always a better way to go. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Marc |
last post by:
Hi all,
I was using Tkinter.IntVar() to store values from a large list of
parts that I pulled from a list. This is the code to initialize the
instances:
def initVariables(self):
self.e =...
|
by: Klaus Johannes Rusch |
last post by:
Is the following code valid and supported by current implementations?
function somename() {
this.show = function () { document.write("somename called") }
}
var somename = new somename();...
|
by: trebor |
last post by:
I added a couple of class files to a VS web project, and I can't access
the application object from inside them. The system treats them like
undeclared variables. Is there an Imports I have to use?...
|
by: Diffident |
last post by:
Hello All,
I have written a webform which is by default derived from "Page" class. I
have coded another utility class with few methods and an object of this class
is instantiated from the webfom...
|
by: Göran Tänzer |
last post by:
Hi,
i've written a class which does some calculations for my web application.
These informatinos are different for each page request - the current user is
not important.
i have about 10 aspx...
|
by: Joseph S. |
last post by:
Hi all,
how do I avoid typing the keyword "$this->" every time I need to
reference a member of a class inside the class?
(coming from a world of cozy auto-complete enabled Java / .Net IDEs I...
|
by: Jesper Schmidt |
last post by:
When does CLR performs initialization of static variables in a class
library?
(1) when the class library is loaded
(2) when a static variable is first referenced
(3) when...
It seems that...
|
by: Justin Voelker |
last post by:
I have a configuration file that contains the host, username,
password, and database name required for any database connections.
The config file runs through a few if/then/else statements to...
|
by: =?Utf-8?B?UGF0Qg==?= |
last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax
code file.
In 1.1 I could have a code behind file for the global.asax file. This allow
for shared variables of the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |