473,379 Members | 1,253 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,379 software developers and data experts.

Use of Modules

I've used modules like I did in VB6, but is there any reason.

If I have a variable in a module because I want it to be available to all
instances could I instead put it the UserControl file and make it shared?
Is that the same?

Nov 20 '05 #1
2 942
" SamSpade" <st**************@REMOVEaol.com> schrieb
I've used modules like I did in VB6, but is there any reason.
Only for simplification.
If I have a variable in a module because I want it to be available to
all instances could I instead put it the UserControl file and make it
shared? Is that the same?


Why Usercontrol? It would be the same if you put it in a class and import it
at project level:

Friend notinheritable class c
private sub new
end sub

public shared x as integer
end class

In addition, add <RootNamespaceOfProject>.c to the project imports and you
have the same as a Module. With Modules this is reached by adding the
Microsoft.VisualBasic.CompilerServices.StandardMod uleAttribute.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
SameSpade,
In addition to Armin's comments.

Using Shared members of classes promotes encapsulation. In that you know
exactly where that Shared member is coming from.

For example:

Public Module SampleModule

Public Shared Function ActiveConnection As SqlConnection
End Function

End Module

Public Class SampleClass

Public Shared Function ActiveConnection As SqlConnection
End Function

End Class

You can use SampleModule.ActiveConnection without qualifying the name with
SampleModule. When you drop SampleModule, you are not certain where the
identifier is coming from.

However with SampleClass.ActiveConnection, you have to qualify the name,
ensuring that you know exactly where ActiveConnection is coming from.

As Armin suggested, you can import the SampleClass itself, allowing you to
use ActiveConnection unqualified. I normally reserve importing classes for
truly global functions, such as System.Math.

Hope this helps
Jay

" SamSpade" <st**************@REMOVEaol.com> wrote in message
news:eq*************@tk2msftngp13.phx.gbl...
I've used modules like I did in VB6, but is there any reason.

If I have a variable in a module because I want it to be available to all
instances could I instead put it the UserControl file and make it shared?
Is that the same?

Nov 20 '05 #3

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

Similar topics

2
by: Dave | last post by:
Hi Everyone, I am trying to import a package and then loop through the modules inside the package, but I'm running to a problem. Basically: ----- I have a package called...
0
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
7
by: Jorgen Grahn | last post by:
I have a set of tests in different modules: test_foo.py, test_bar.py and so on. All of these use the simplest possible internal layout: a number of classes containing test*() methods, and the good...
4
by: Misto . | last post by:
Hi folks! Short: There is a way to dumplicate a module ? I tried copy.deepcopy(module) but hangs with an error (also with standard modules ).. The only solution that I have by now is...
2
by: James Buchanan | last post by:
Hi group, I'm preparing Python 2.4.2 for the upcoming Minix 3.x release, and I have problems with make. configure runs fine and creates the makefile, but right at the end ends with an error...
7
by: Lauren Quantrell | last post by:
At running the risk of asking how big is too big... Is there a rule of thumb or a best practice that says I may have too many modules? I currently have a Access2K app with about 30 code modules,...
13
by: Robin Haswell | last post by:
Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules...
173
by: Zytan | last post by:
I've read the docs on this, but one thing was left unclear. It seems as though a Module does not have to be fully qualified. Is this the case? I have source that apparently shows this. Are...
3
by: Mohamed Yousef | last post by:
Hello , The problem I'm asking about is how can imported modules be aware of other imported modules so they don't have to re-import them (avoiding importing problems and Consicing code and...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
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
0
BarryA
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...
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...

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.