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

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 3592
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Johm | last post by:
In my codes i am often referring to one and the same controls.Is it possible to declare these controls only once and then insert them in all my functions and subs? For example, i am often...
1
by: JMCN | last post by:
hello- i received an runtime error message: You tried to call Update or CancelUpdate or attempted to update a Field in a recordset without first calling AddNew or Edit. (Error 3020). when i look...
5
by: MMSJED | last post by:
I am beginner in using C#, actually I am trying to move from VB6 to C# I need very small help in programming problem my be you will laugh when you get it That simply I have to form let’s say...
1
by: MMSJED | last post by:
I am beginner in using C#, actually I am trying to move from VB6 to C# I need very small maybe you will laugh when you get it that simply I have 2 forms let’s say Form1 (main form) and Form2 and...
15
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have ...
3
by: Ken Adeniji | last post by:
Must declare the scalar variable '@FirstName' ContactGridViewWebForm.aspx <aspqlDataSource RunAt="server" ID="SqlDataSourceContact" ...
2
by: Mamatha | last post by:
Hi If any one knows,please tell me how can we declare a public variable in methods of VB.NET like public indx as integer. How can i use that variable in another methods like global...
6
by: **Developer** | last post by:
Notice below I sometimes used the "A" version. I found by cut-and-try that only the "A" version would work correctly. Anyone have a suggestion of why the "W" version would not work correctly? ...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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...

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.