PC Review


Reply
Thread Tools Rate Thread

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

 
 
MJ
Guest
Posts: n/a
 
      14th Dec 2003
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...
 
Reply With Quote
 
 
 
 
Cor
Guest
Posts: n/a
 
      14th Dec 2003
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?



 
Reply With Quote
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      14th Dec 2003
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" <(E-Mail Removed)> wrote in message
news:1382101c3c219$fe439a00$(E-Mail Removed)...
> 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...



 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      14th Dec 2003
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


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      14th Dec 2003
* "MJ" <(E-Mail Removed)> 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>
 
Reply With Quote
 
One Handed Man [ OHM# ]
Guest
Posts: n/a
 
      14th Dec 2003
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# (E-Mail Removed)


 
Reply With Quote
 
One Handed Man [ OHM# ]
Guest
Posts: n/a
 
      14th Dec 2003
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# (E-Mail Removed)


 
Reply With Quote
 
Charlie Smith
Guest
Posts: n/a
 
      14th Dec 2003
MJ,

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


> "MJ" <(E-Mail Removed)> wrote in message
> news:1382101c3c219$fe439a00$(E-Mail Removed)...
> > 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...

 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      14th Dec 2003
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:(E-Mail Removed)...
> 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# (E-Mail Removed)
>
>



 
Reply With Quote
 
One Handed Man [ OHM# ]
Guest
Posts: n/a
 
      14th Dec 2003
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:(E-Mail Removed)...
>> 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# (E-Mail Removed)


Regards - OHM# (E-Mail Removed)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to declare Public variable esha Microsoft C# .NET 15 14th Sep 2006 05:49 PM
Declare public variable in C# =?Utf-8?B?TU1TSkVE?= Microsoft C# .NET 5 1st Aug 2005 02:50 PM
Declare public variable in C#1 =?Utf-8?B?TU1TSkVE?= Microsoft C# .NET 1 1st Aug 2005 12:05 PM
How to declare variable as public. =?Utf-8?B?TWFyaw==?= Microsoft Excel Programming 3 7th Apr 2005 06:27 PM
I would like to declare a Public Function or Public Variable Henro Microsoft Access Getting Started 2 1st Dec 2003 04:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:33 PM.