469,945 Members | 2,262 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

How declare a public variable that can be edit by forms?VB.Net

MJ
as topic, if i wan to create an array where the content of
the array can be edited by form1 and form2, how i going to
do it?
for example the content of array is {1,2,3}

form2 change the content to {1,2,4}

form1 also can see the changes in the array
where i should declare the array and wat is the format?
and how am i going to call the array in form1 and form2
for modification?
any help is greatly appreciated...thz...
Nov 20 '05 #1
13 3459
Cor
Hi MJ,

If it is a fixed array you can do making a shared class as this

Public Class mySample
Private Shared myRealArray As Integer() = {1, 2, 3}
Public Shared Property MyArray() As Integer()
Get
Return myRealArray
End Get
Set(ByVal Value As Integer())
myRealArray = Value
End Set
End Property
End Class

Now you can use everywhere that array by
mySample.myArray(2) = 4

But have a look at arraylist also, because this is not such a nice example,
I did try to answer your question exactly as you was asking. If you want to
redim your array, you have to add a method to your class. (public shared Sub
or function)

I hope this helps,

Cor

as topic, if i wan to create an array where the content of
the array can be edited by form1 and form2, how i going to
do it?
for example the content of array is {1,2,3}

form2 change the content to {1,2,4}

form1 also can see the changes in the array
where i should declare the array and wat is the format?
and how am i going to call the array in form1 and form2
for modification?

Nov 20 '05 #2
Hi,

In addition to Cor's comments you need to make a public array in a
module to make available through the project.

Public myArray() As Integer = {1, 2, 3}
Ken
--------------------
"MJ" <mj*****@pd.jaring.my> wrote in message
news:13*****************************@phx.gbl...
as topic, if i wan to create an array where the content of
the array can be edited by form1 and form2, how i going to
do it?
for example the content of array is {1,2,3}

form2 change the content to {1,2,4}

form1 also can see the changes in the array
where i should declare the array and wat is the format?
and how am i going to call the array in form1 and form2
for modification?
any help is greatly appreciated...thz...

Nov 20 '05 #3
Cor
Hi Ken,
In addition to Cor's comments you need to make a public array in a
module to make available through the project.

Sorry for trying correctiong you, but I think you did want to say

In addition to Cor's comments you can also make a public array in a
module to make available through the project.

If I dont post this the OP does maybe understand it wrong and does both.

:-)

Cor
Nov 20 '05 #4
* "MJ" <mj*****@pd.jaring.my> scripsit:
as topic, if i wan to create an array where the content of
the array can be edited by form1 and form2, how i going to
do it?
for example the content of array is {1,2,3}

form2 change the content to {1,2,4}

form1 also can see the changes in the array
where i should declare the array and wat is the format?
and how am i going to call the array in form1 and form2
for modification?
any help is greatly appreciated...thz...


Place the array declaration in a module or a class (declared as
'Shared'), for example:

\\\
Public Module Globals
Private m_MyArray() As Integer

Public Property MyArray() As Integer()
Get
Return m_MyArray
End Get
Set(ByVal Value As Integer())
m_MyArray = Value
End Set
End Property
End Module
///

Access the array with 'Globals.MyArray'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5
I thought that as well Cor.

Regards - OHM#

Cor wrote:
Hi Ken,
In addition to Cor's comments you need to make a public array in a
module to make available through the project.

Sorry for trying correctiong you, but I think you did want to say

In addition to Cor's comments you can also make a public array in a
module to make available through the project.

If I dont post this the OP does maybe understand it wrong and does
both.

:-)

Cor


Regards - OHM# On**********@BTInternet.com
Nov 20 '05 #6
PS:

I prefer your method to create a Class rather than declaring an array in the
Module
Cor wrote:
Hi Ken,
In addition to Cor's comments you need to make a public array in a
module to make available through the project.

Sorry for trying correctiong you, but I think you did want to say

In addition to Cor's comments you can also make a public array in a
module to make available through the project.

If I dont post this the OP does maybe understand it wrong and does
both.

:-)

Cor


Regards - OHM# On**********@BTInternet.com
Nov 20 '05 #7
MJ,

You might also want to create an isChanged event in the class to
notify the other form when one changes it.

"MJ" <mj*****@pd.jaring.my> wrote in message
news:13*****************************@phx.gbl...
as topic, if i wan to create an array where the content of
the array can be edited by form1 and form2, how i going to
do it?
for example the content of array is {1,2,3}

form2 change the content to {1,2,4}

form1 also can see the changes in the array
where i should declare the array and wat is the format?
and how am i going to call the array in form1 and form2
for modification?
any help is greatly appreciated...thz...

Nov 20 '05 #8
OHM,
I prefer the shared variable in a Class (Cor's example) as well, as its
better "encapsulated". Other developers know that the array is coming from
that class, where as with a Module the array could be coming from any number
of modules.

I normally only use Modules for truly global functions, such as Math
functions. However even then sometimes I will make a class with only Shared
functions.

Jay
"One Handed Man [ OHM# ]" <OneHandedMan@&REMOVE&TO%MAIL%MEBTInternet.com>
wrote in message news:uW**************@tk2msftngp13.phx.gbl...
PS:

I prefer your method to create a Class rather than declaring an array in the Module
Cor wrote:
Hi Ken,
In addition to Cor's comments you need to make a public array in a
module to make available through the project.

Sorry for trying correctiong you, but I think you did want to say

In addition to Cor's comments you can also make a public array in a
module to make available through the project.

If I dont post this the OP does maybe understand it wrong and does
both.

:-)

Cor


Regards - OHM# On**********@BTInternet.com

Nov 20 '05 #9
erm. Thats what I said !

<confused> - OHM#

Jay B. Harlow [MVP - Outlook] wrote:
OHM,
I prefer the shared variable in a Class (Cor's example) as well, as
its better "encapsulated". Other developers know that the array is
coming from that class, where as with a Module the array could be
coming from any number of modules.

I normally only use Modules for truly global functions, such as Math
functions. However even then sometimes I will make a class with only
Shared functions.

Jay
"One Handed Man [ OHM# ]"
<OneHandedMan@&REMOVE&TO%MAIL%MEBTInternet.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
PS:

I prefer your method to create a Class rather than declaring an
array in the Module
Cor wrote:
Hi Ken,

In addition to Cor's comments you need to make a public array in a
module to make available through the project.
Sorry for trying correctiong you, but I think you did want to say

In addition to Cor's comments you can also make a public array in a
module to make available through the project.

If I dont post this the OP does maybe understand it wrong and does
both.

:-)

Cor


Regards - OHM# On**********@BTInternet.com


Regards - OHM# On**********@BTInternet.com
Nov 20 '05 #10
Hi,

Sorry. You are correct.

Ken
--------
"Cor" <no*@non.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Ken,
In addition to Cor's comments you need to make a public array in a
module to make available through the project.

Sorry for trying correctiong you, but I think you did want to say

In addition to Cor's comments you can also make a public array in a
module to make available through the project.

If I dont post this the OP does maybe understand it wrong and does both.

:-)

Cor

Nov 20 '05 #11
OHM,
Yes I was agreeing with you & Cor!

I did not mean to confuse you, it was more re-iterate what you stated, plus
add a caution of using modules in general...

Jay
"One Handed Man [ OHM# ]" <OneHandedMan@&REMOVE&TO%MAIL%MEBTInternet.com>
wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...
erm. Thats what I said !

<confused> - OHM#

Jay B. Harlow [MVP - Outlook] wrote:
OHM,
I prefer the shared variable in a Class (Cor's example) as well, as
its better "encapsulated". Other developers know that the array is
coming from that class, where as with a Module the array could be
coming from any number of modules.

I normally only use Modules for truly global functions, such as Math
functions. However even then sometimes I will make a class with only
Shared functions.

Jay
"One Handed Man [ OHM# ]"
<OneHandedMan@&REMOVE&TO%MAIL%MEBTInternet.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
PS:

I prefer your method to create a Class rather than declaring an
array in the Module
Cor wrote:
Hi Ken,

> In addition to Cor's comments you need to make a public array in a
> module to make available through the project.
Sorry for trying correctiong you, but I think you did want to say

In addition to Cor's comments you can also make a public array in a
module to make available through the project.

If I dont post this the OP does maybe understand it wrong and does
both.

:-)

Cor

Regards - OHM# On**********@BTInternet.com


Regards - OHM# On**********@BTInternet.com

Nov 20 '05 #12

LOL, I'm easily confused today as I have a chest infection. Just ignore me.

Cheers - OHM#

Jay B. Harlow [MVP - Outlook] wrote:
OHM,
Yes I was agreeing with you & Cor!

I did not mean to confuse you, it was more re-iterate what you
stated, plus add a caution of using modules in general...

Jay
"One Handed Man [ OHM# ]"
<OneHandedMan@&REMOVE&TO%MAIL%MEBTInternet.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
erm. Thats what I said !

<confused> - OHM#

Jay B. Harlow [MVP - Outlook] wrote:
OHM,
I prefer the shared variable in a Class (Cor's example) as well, as
its better "encapsulated". Other developers know that the array is
coming from that class, where as with a Module the array could be
coming from any number of modules.

I normally only use Modules for truly global functions, such as Math
functions. However even then sometimes I will make a class with only
Shared functions.

Jay
"One Handed Man [ OHM# ]"
<OneHandedMan@&REMOVE&TO%MAIL%MEBTInternet.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
PS:

I prefer your method to create a Class rather than declaring an
array in the Module
Cor wrote:
> Hi Ken,
>
>> In addition to Cor's comments you need to make a public array in
>> a module to make available through the project.
>
>
> Sorry for trying correctiong you, but I think you did want to say
>
> In addition to Cor's comments you can also make a public array in
> a module to make available through the project.
>
> If I dont post this the OP does maybe understand it wrong and does
> both.
>
> :-)
>
> Cor

Regards - OHM# On**********@BTInternet.com


Regards - OHM# On**********@BTInternet.com


Regards - OHM# On**********@BTInternet.com
Nov 20 '05 #13

LOL, I'm easily confused today as I have a chest infection. Just ignore me.

Cheers - OHM#

Jay B. Harlow [MVP - Outlook] wrote:
OHM,
Yes I was agreeing with you & Cor!

I did not mean to confuse you, it was more re-iterate what you
stated, plus add a caution of using modules in general...

Jay
"One Handed Man [ OHM# ]"
<OneHandedMan@&REMOVE&TO%MAIL%MEBTInternet.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
erm. Thats what I said !

<confused> - OHM#

Jay B. Harlow [MVP - Outlook] wrote:
OHM,
I prefer the shared variable in a Class (Cor's example) as well, as
its better "encapsulated". Other developers know that the array is
coming from that class, where as with a Module the array could be
coming from any number of modules.

I normally only use Modules for truly global functions, such as Math
functions. However even then sometimes I will make a class with only
Shared functions.

Jay
"One Handed Man [ OHM# ]"
<OneHandedMan@&REMOVE&TO%MAIL%MEBTInternet.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
PS:

I prefer your method to create a Class rather than declaring an
array in the Module
Cor wrote:
> Hi Ken,
>
>> In addition to Cor's comments you need to make a public array in
>> a module to make available through the project.
>
>
> Sorry for trying correctiong you, but I think you did want to say
>
> In addition to Cor's comments you can also make a public array in
> a module to make available through the project.
>
> If I dont post this the OP does maybe understand it wrong and does
> both.
>
> :-)
>
> Cor

Regards - OHM# On**********@BTInternet.com


Regards - OHM# On**********@BTInternet.com


Regards - OHM# On**********@BTInternet.com
Nov 20 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Johm | last post: by
5 posts views Thread by MMSJED | last post: by
1 post views Thread by MMSJED | last post: by
15 posts views Thread by Geoff Cox | last post: by
3 posts views Thread by Ken Adeniji | last post: by
6 posts views Thread by **Developer** | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.