473,503 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Variable declarations.... in VB.Net

In my program I will be using the common structure repeatedly in a module.
Ex Member.FirstName, Member.LastName..

How to declare it in one common place, so that I can create an instance of
this variable and use in sub procedure or function as local variable.

Currently I am declaring these set of variables in each sub or function.

VB.Net 2003 and .Net Framework 1.1

Thank you,

Pete
Feb 3 '06 #1
5 1870
Put the structure definition in a public module and declare it a public
structure

Module Globals
Public Structure Member
FirstName as string
LastName as string
end structure
end module

When you need to use it in a sub or function:

module (or class) mycode
sub Main()
dim m as Member

m.FirstName = "Mike"
m.Lastname = "Ober"
end sub
end Module (or class)

Mike Ober.

"Pete Smith" <Pe*********@hotmail.com> wrote in message
news:eI*************@tk2msftngp13.phx.gbl...
In my program I will be using the common structure repeatedly in a module.
Ex Member.FirstName, Member.LastName..

How to declare it in one common place, so that I can create an instance of
this variable and use in sub procedure or function as local variable.

Currently I am declaring these set of variables in each sub or function.

VB.Net 2003 and .Net Framework 1.1

Thank you,

Pete


Feb 4 '06 #2
Put the declaration after any "Imports..." declarations and before the class
declaration. Is should be available in all classes and modules in your
project, i.e.,

Imports xxxxxx
Public Structure myStructure
FirstName as string
LastName as string
End Structure

Public (or Friend) Class myClass

.........
End Class

--
Dennis in Houston
"Pete Smith" wrote:
In my program I will be using the common structure repeatedly in a module.
Ex Member.FirstName, Member.LastName..

How to declare it in one common place, so that I can create an instance of
this variable and use in sub procedure or function as local variable.

Currently I am declaring these set of variables in each sub or function.

VB.Net 2003 and .Net Framework 1.1

Thank you,

Pete

Feb 4 '06 #3

in my personal opinion the usage of a module should be avoided ( when
possible ) so i would go for Dennis`s aproach
although i would go for a friend scoped declaration unless i explicitly
want an object to be public ( thus also outside my own assembly )
regards

Michel Posseth [MCP]
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:A8**********************************@microsof t.com...
Put the declaration after any "Imports..." declarations and before the
class
declaration. Is should be available in all classes and modules in your
project, i.e.,

Imports xxxxxx
Public Structure myStructure
FirstName as string
LastName as string
End Structure

Public (or Friend) Class myClass

........
End Class

--
Dennis in Houston
"Pete Smith" wrote:
In my program I will be using the common structure repeatedly in a
module.
Ex Member.FirstName, Member.LastName..

How to declare it in one common place, so that I can create an instance
of
this variable and use in sub procedure or function as local variable.

Currently I am declaring these set of variables in each sub or function.

VB.Net 2003 and .Net Framework 1.1

Thank you,

Pete

Feb 5 '06 #4
Sorry, I'm an old VB 6 user and I wrote that off the top of my head.
Dennis is correct in that the structure should stand on it's own.

Mike Ober.

"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

in my personal opinion the usage of a module should be avoided ( when
possible ) so i would go for Dennis`s aproach
although i would go for a friend scoped declaration unless i explicitly
want an object to be public ( thus also outside my own assembly )
regards

Michel Posseth [MCP]
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:A8**********************************@microsof t.com...
Put the declaration after any "Imports..." declarations and before the
class
declaration. Is should be available in all classes and modules in your
project, i.e.,

Imports xxxxxx
Public Structure myStructure
FirstName as string
LastName as string
End Structure

Public (or Friend) Class myClass

........
End Class

--
Dennis in Houston
"Pete Smith" wrote:
In my program I will be using the common structure repeatedly in a
module.
Ex Member.FirstName, Member.LastName..

How to declare it in one common place, so that I can create an instance
of
this variable and use in sub procedure or function as local variable.

Currently I am declaring these set of variables in each sub or function.
VB.Net 2003 and .Net Framework 1.1

Thank you,

Pete



Feb 5 '06 #5
Thank you all for your response.
-Pete
"Michael D. Ober" <obermd.@.alum.mit.edu.nospam> wrote in message
news:NU*****************@newsread1.news.pas.earthl ink.net...
Sorry, I'm an old VB 6 user and I wrote that off the top of my head.
Dennis is correct in that the structure should stand on it's own.

Mike Ober.

"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

in my personal opinion the usage of a module should be avoided ( when
possible ) so i would go for Dennis`s aproach
although i would go for a friend scoped declaration unless i explicitly
want an object to be public ( thus also outside my own assembly )
regards

Michel Posseth [MCP]
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:A8**********************************@microsof t.com...
Put the declaration after any "Imports..." declarations and before the
class
declaration. Is should be available in all classes and modules in your project, i.e.,

Imports xxxxxx
Public Structure myStructure
FirstName as string
LastName as string
End Structure

Public (or Friend) Class myClass

........
End Class

--
Dennis in Houston
"Pete Smith" wrote:

> In my program I will be using the common structure repeatedly in a
> module.
> Ex Member.FirstName, Member.LastName..
>
> How to declare it in one common place, so that I can create an instance> of
> this variable and use in sub procedure or function as local variable.>
> Currently I am declaring these set of variables in each sub or function.>
> VB.Net 2003 and .Net Framework 1.1
>
> Thank you,
>
> Pete
>
>
>



Feb 7 '06 #6

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

Similar topics

83
6421
by: Alexander Zatvornitskiy | last post by:
Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in Pascal, or special syntax in...
134
7746
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
0
1217
by: Fried Egg | last post by:
* Codetag PEP: ** I would like to comment on the codetags PEP, which I give a 0+. I think the end "<>" is bad; I would be in favor of a block system or something that looks more like regular...
8
1807
by: Jim Moon | last post by:
Hi. I'm curious about this syntax: <variable>=function(){...} I'm not finding a definition of this syntax, but I see it used at this website:...
7
7695
by: seamoon | last post by:
Hi, I'm doing a simple compiler with C as a target language. My language uses the possibility to declare variables anywhere in a block with scope to the end of the block. As I remembered it this...
7
1437
by: Antonio | last post by:
I'm developing the firmware for a slave in a comunication channel. Now there is certain information (namely the addresses of the slave and the master) that must be changeable while the device is up...
22
2254
by: James Brodie | last post by:
I just wanted to get some advice on what are the better practices: 1) Should variables be declared at the beginning of a function or just before they are required? 2) Should all variabled be...
26
2517
by: samjnaa | last post by:
Hello. Please tell me whether this feature request is sane (and not done before) for python so it can be posted to the python-dev mailing list. I should say first that I am not a professional...
2
4691
by: Shraddha | last post by:
Can we declare extern variable as static? What will be the scope of the variable then? What if we change the value of the variable in some other function? Also can someone tell me that if we can...
11
8292
by: Jef Driesen | last post by:
I have the following problem in a C project (but that also needs to compile with a C++ compiler). I'm using a virtual function table, that looks like this in the header file: typedef struct...
0
7323
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
6984
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
7453
tracyyun
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...
0
5576
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
5005
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
4670
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
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
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...

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.