473,473 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Module or Code file ?

I want to write a program with many sub-method.
for example,
1)method :company_search(code) which return name,addresss...etc
2)method:currency(code) which return the current exchange rate....etc
..... manys

Should I write it use module ??? or in code file ??
What is the difference about it ?
Thanks
From Agnes
Nov 20 '05 #1
5 6096
A module is merely a class so ultimately there's no difference between a
module and a class -- however modules have all of their properties/methods
that are shared. If you create a sealed class, and make all of the
methods/properties shared, you'll be in the same boat. Many things lend
themselves to static methods (File.Exists) others to instances Dim fi as
new FileInfo

It really depends on the ultimate usage. Modules are convenient in that you
don't have to prefix them, but that can also cause some trouble in some
instances b/c a name in your class shares a name w/ the module. You can
kill the variable you have locally or change its name and you won't see any
immediate errors if they were both of the same type (and if you have option
strict off [which should be outlawed], it's possible even then. C# also
doesn't support modules so using the class driven approach may be more
comfortable programming in both environments.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I want to write a program with many sub-method.
for example,
1)method :company_search(code) which return name,addresss...etc
2)method:currency(code) which return the current exchange rate....etc
.... manys

Should I write it use module ??? or in code file ??
What is the difference about it ?
Thanks
From Agnes

Nov 20 '05 #2
Hi Agnes,

In addition to Bill, in my opinion is it only good programming to use a
module in a real small application or in a VB6 upgrade project.

In VB.net I use classes. There are two types; the names are so called names.
- The shared class (which contains a lot (mostly all) of shared methods
and properties)
- The non-shared class

From a non-shared class you have to create an object in your programming by
instancing them.
Dim mynewClassObject as New myNonSharedClass.
Dim myvalue = mynewClassObject.value

Shared members, events and properties in a class can directly called by
their name
Dim myvalue = mySharedClass.value

The benefit above a module is that you shall call them instancing or using
their name, with which they become immediately recognizable in your project.

The benefit from a non-shared class above a shared class is that it uses
less memory. It goes out of scope when the procedure ends where it is in
created (which is not true, the truth is when there are no references
anymore to it).

I hope this helps?

Cor
Nov 20 '05 #3
Hi Agnes,

In addition to Bill, in my opinion is it only good programming to use a
module in a real small application or in a VB6 upgrade project.

In VB.net I use classes. There are two types; the names are so called names.
- The shared class (which contains a lot (mostly all) of shared methods
and properties)
- The non-shared class

From a non-shared class you have to create an object in your programming by
instancing them.
Dim mynewClassObject as New myNonSharedClass.
Dim myvalue = mynewClassObject.value

Shared members, events and properties in a class can directly called by
their name
Dim myvalue = mySharedClass.value

The benefit above a module is that you shall call them instancing or using
their name, with which they become immediately recognizable in your project.

The benefit from a non-shared class above a shared class is that it uses
less memory. It goes out of scope when the procedure ends where it is in
created (which is not true, the truth is when there are no references
anymore to it).

I hope this helps?

Cor
Nov 20 '05 #4
* "Agnes" <ag***@dynamictech.com.hk> scripsit:
I want to write a program with many sub-method.
for example,
1)method :company_search(code) which return name,addresss...etc
2)method:currency(code) which return the current exchange rate....etc
.... manys

Should I write it use module ??? or in code file ??


In addition to the other replies:

Have a look at this chapter in the documentation -- it will provide an
introduction to object oriented programming with VB.NET:

<URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vbconprogrammingwithobjects.asp>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5
* "Agnes" <ag***@dynamictech.com.hk> scripsit:
I want to write a program with many sub-method.
for example,
1)method :company_search(code) which return name,addresss...etc
2)method:currency(code) which return the current exchange rate....etc
.... manys

Should I write it use module ??? or in code file ??


In addition to the other replies:

Have a look at this chapter in the documentation -- it will provide an
introduction to object oriented programming with VB.NET:

<URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vbconprogrammingwithobjects.asp>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6

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

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
2
by: Marc Shapiro | last post by:
I am relatively new to python (I have used it on and off for a few small projects over the last few years) so I imagine that what I am trying to do has already been done, but practical experience,...
1
by: Peter Åstrand | last post by:
There's a new PEP available: PEP 324: popen5 - New POSIX process module A copy is included below. Comments are appreciated. ---- PEP: 324 Title: popen5 - New POSIX process module
8
by: Irmen de Jong | last post by:
What would be the best way, if any, to obtain the bytecode for a given loaded module? I can get the source: import inspect import os src = inspect.getsource(os) but there is no...
8
by: Philippe C. Martin | last post by:
Hi, I'm getting pretty desperate here: The code below crashes on the last line (but works from a shell). The class 'BC' exists and the loop on self.__BC_EXEC_LIST passes fine. It's got to...
2
by: Kenneth McDonald | last post by:
I'd like to propose a new PEP , for a standard library module that deals with files and file paths in an object oriented manner. I believe this module should be included as part of the standard...
12
by: Steven Bethard | last post by:
Ok, so I have a module that is basically a Python wrapper around a big lookup table stored in a text file. The module needs to provide a few functions:: get_stem(word, pos, default=None)...
10
by: Ben Finney | last post by:
Howdy all, Question: I have Python modules named without '.py' as the extension, and I'd like to be able to import them. How can I do that? Background: On Unix, I write programs intended to...
1
by: alain MONTMORY | last post by:
Hello everybody, I am a newbie to python so I hope I am at the right place to expose my problem..... :-http://www.python.org/doc/2.4.2/ext/pure-embedding.html 5.3 Pure Embedding I download the...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
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...
1
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
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,...
1
isladogs
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.