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

ArrayList as a Property type

This doesn't work. I guess New is needed someplace but I don't know where?

Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info
Nov 21 '05 #1
11 1460
Hi,

Store a local copy of the arraylist to return in the property.

Public Property Filters as ArrayList

Get
Dim marFilters as New Arraylist
marFilters.Add(cboFilter.text)
return marFilters
end get
Ken
-----------------------
" Just Me" <ne********@a-znet.com> wrote in message
news:Ok****************@tk2msftngp13.phx.gbl...
This doesn't work. I guess New is needed someplace but I don't know where?

Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info

Nov 21 '05 #2

August 10, 2004

The property does not maintain an instance of ArrayList itself.
You also have the concept of the property wrong. What you should
do is create a page level variable of ArrayList and then create a
sub that you call to add a filter. Then if you want to retrieve the
filters,
just access the arraylist variable directly. This looks something like:

dim filters as new ArrayList

Private Sub AddFilter()
filters.add(cbofilter.text)
End Sub

Private Sub Button1_Click(....)
if filters(0) = "Something" then
.... ' do something with list
End Sub

A property is maintained by something like this:

dim _userinput as string

Public Property UserInput() as String
Get
return _userinput
End Get
Set (byval value as string)
_userinput = value
End Set
End Property

Then you can use the property like this: Class.Userinput = Something.
I hope this makes sense! Have a good day!
Joseph MCP
"Just Me" wrote:
This doesn't work. I guess New is needed someplace but I don't know where?

Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info

Nov 21 '05 #3

August 10, 2004

Wouldn't the marFilters go out of scope in your example?
Also, to only have a Get statement, the property declaration
must be marked as ReadOnly. That also looks suspiciously like
a function...

Joseph MCP
"Ken Tucker [MVP]" wrote:
Hi,

Store a local copy of the arraylist to return in the property.

Public Property Filters as ArrayList

Get
Dim marFilters as New Arraylist
marFilters.Add(cboFilter.text)
return marFilters
end get
Ken
-----------------------
" Just Me" <ne********@a-znet.com> wrote in message
news:Ok****************@tk2msftngp13.phx.gbl...
This doesn't work. I guess New is needed someplace but I don't know where?

Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info

Nov 21 '05 #4
Seems to work for me
Thanks

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
Hi,

Store a local copy of the arraylist to return in the property.

Public Property Filters as ArrayList

Get
Dim marFilters as New Arraylist
marFilters.Add(cboFilter.text)
return marFilters
end get
Ken
-----------------------
" Just Me" <ne********@a-znet.com> wrote in message
news:Ok****************@tk2msftngp13.phx.gbl...
This doesn't work. I guess New is needed someplace but I don't know where?

Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info

Nov 21 '05 #5
Can someone confirm this??
The reference variable would go out of scope but the instance would not get
GC since there would still be a reference in the return.

"Joseph MCP" <Jo*******@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.com...

August 10, 2004

Wouldn't the marFilters go out of scope in your example?
Also, to only have a Get statement, the property declaration
must be marked as ReadOnly. That also looks suspiciously like
a function...

Joseph MCP

"Ken Tucker [MVP]" wrote:
Hi,

Store a local copy of the arraylist to return in the property.

Public Property Filters as ArrayList

Get
Dim marFilters as New Arraylist
marFilters.Add(cboFilter.text)
return marFilters
end get
Ken
-----------------------
" Just Me" <ne********@a-znet.com> wrote in message
news:Ok****************@tk2msftngp13.phx.gbl...
This doesn't work. I guess New is needed someplace but I don't know where?
Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info

Nov 21 '05 #6
Thanks for the reply. It's getting late and I'm not too sharp but I'm having
a problem following your reply.

In a sense I already have a class level variable with the data in it (for
Get); or into which I want to put the data (with Set)
It is a combobox. The property is to get that data or set it.
With that said, do you still think what you wrote applies?

Thanks
"Joseph MCP" <Jo*******@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...

August 10, 2004

The property does not maintain an instance of ArrayList itself.
You also have the concept of the property wrong. What you should
do is create a page level variable of ArrayList and then create a
sub that you call to add a filter. Then if you want to retrieve the
filters,
just access the arraylist variable directly. This looks something like:
dim filters as new ArrayList

Private Sub AddFilter()
filters.add(cbofilter.text)
End Sub

Private Sub Button1_Click(....)
if filters(0) = "Something" then
.... ' do something with list
End Sub

A property is maintained by something like this:

dim _userinput as string

Public Property UserInput() as String
Get
return _userinput
End Get
Set (byval value as string)
_userinput = value
End Set
End Property

Then you can use the property like this: Class.Userinput = Something. I hope this makes sense! Have a good day!
Joseph MCP
"Just Me" wrote:
This doesn't work. I guess New is needed someplace but I don't know where?
Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info

Nov 21 '05 #7
* " Just Me" <ne********@a-znet.com> scripsit:
This doesn't work. I guess New is needed someplace but I don't know where?

Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)


\\\
Private m_Filters As New ArrayList()

Public Property Filters() As ArrayList
Get
Return m_Filters
End Get
Set(ByVal Value As ArrayList)
m_Filters = Value
End Set
End Property
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #8

August 10, 2004

I sounds like you already were doing the equivilant of what I wrote,
so the answer is no. But now you have me confused of what the problem
is? :-) Maybe I just need to review the posts again. Good job!
Joseph MCP

"Just Me" wrote:
Thanks for the reply. It's getting late and I'm not too sharp but I'm having
a problem following your reply.

In a sense I already have a class level variable with the data in it (for
Get); or into which I want to put the data (with Set)
It is a combobox. The property is to get that data or set it.
With that said, do you still think what you wrote applies?

Thanks
"Joseph MCP" <Jo*******@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...

August 10, 2004

The property does not maintain an instance of ArrayList itself.
You also have the concept of the property wrong. What you should
do is create a page level variable of ArrayList and then create a
sub that you call to add a filter. Then if you want to retrieve the
filters,
just access the arraylist variable directly. This looks something

like:

dim filters as new ArrayList

Private Sub AddFilter()
filters.add(cbofilter.text)
End Sub

Private Sub Button1_Click(....)
if filters(0) = "Something" then
.... ' do something with list
End Sub

A property is maintained by something like this:

dim _userinput as string

Public Property UserInput() as String
Get
return _userinput
End Get
Set (byval value as string)
_userinput = value
End Set
End Property

Then you can use the property like this: Class.Userinput =

Something.
I hope this makes sense! Have a good day!
Joseph MCP
"Just Me" wrote:
This doesn't work. I guess New is needed someplace but I don't know where?
Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info


Nov 21 '05 #9

August 10, 2004

By the way, in reviewing the posts, I don't think you have the property
concept wrong. You've got it right. I was more in the mind-set of
functions,
as I didn't see the full code. Good job!
Joseph MCP

"Just Me" wrote:
Thanks for the reply. It's getting late and I'm not too sharp but I'm having
a problem following your reply.

In a sense I already have a class level variable with the data in it (for
Get); or into which I want to put the data (with Set)
It is a combobox. The property is to get that data or set it.
With that said, do you still think what you wrote applies?

Thanks
"Joseph MCP" <Jo*******@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...

August 10, 2004

The property does not maintain an instance of ArrayList itself.
You also have the concept of the property wrong. What you should
do is create a page level variable of ArrayList and then create a
sub that you call to add a filter. Then if you want to retrieve the
filters,
just access the arraylist variable directly. This looks something

like:

dim filters as new ArrayList

Private Sub AddFilter()
filters.add(cbofilter.text)
End Sub

Private Sub Button1_Click(....)
if filters(0) = "Something" then
.... ' do something with list
End Sub

A property is maintained by something like this:

dim _userinput as string

Public Property UserInput() as String
Get
return _userinput
End Get
Set (byval value as string)
_userinput = value
End Set
End Property

Then you can use the property like this: Class.Userinput =

Something.
I hope this makes sense! Have a good day!
Joseph MCP
"Just Me" wrote:
This doesn't work. I guess New is needed someplace but I don't know where?
Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info


Nov 21 '05 #10
Thanks for spending so much time

"Joseph MCP" <Jo*******@discussions.microsoft.com> wrote in message
news:C7**********************************@microsof t.com...

August 10, 2004

By the way, in reviewing the posts, I don't think you have the property concept wrong. You've got it right. I was more in the mind-set of
functions,
as I didn't see the full code. Good job!
Joseph MCP

"Just Me" wrote:
Thanks for the reply. It's getting late and I'm not too sharp but I'm having a problem following your reply.

In a sense I already have a class level variable with the data in it (for Get); or into which I want to put the data (with Set)
It is a combobox. The property is to get that data or set it.
With that said, do you still think what you wrote applies?

Thanks
"Joseph MCP" <Jo*******@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...

August 10, 2004

The property does not maintain an instance of ArrayList itself. You also have the concept of the property wrong. What you should
do is create a page level variable of ArrayList and then create a sub that you call to add a filter. Then if you want to retrieve the filters,
just access the arraylist variable directly. This looks
something like:

dim filters as new ArrayList

Private Sub AddFilter()
filters.add(cbofilter.text)
End Sub

Private Sub Button1_Click(....)
if filters(0) = "Something" then
.... ' do something with list
End Sub

A property is maintained by something like this:

dim _userinput as string

Public Property UserInput() as String
Get
return _userinput
End Get
Set (byval value as string)
_userinput = value
End Set
End Property

Then you can use the property like this: Class.Userinput =

Something.
I hope this makes sense! Have a good day!
Joseph MCP
"Just Me" wrote:

> This doesn't work. I guess New is needed someplace but I don't know

where?
>
>
>
> Public Property Filters() As ArrayList
>
> Get
>
> Filters.Add(cboFilter.Text)
>
> ---snip--
>
> Thanks in advance for any info
>
>
>


Nov 21 '05 #11
Thanks

I remember someone asking what the Return was for.
At the time I thought it was just another way to proceed but I guess it's
more than that.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:es**************@tk2msftngp13.phx.gbl...
* " Just Me" <ne********@a-znet.com> scripsit:
This doesn't work. I guess New is needed someplace but I don't know where?
Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)


\\\
Private m_Filters As New ArrayList()

Public Property Filters() As ArrayList
Get
Return m_Filters
End Get
Set(ByVal Value As ArrayList)
m_Filters = Value
End Set
End Property
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #12

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

Similar topics

1
by: Jamus Sprinson | last post by:
Before I continue, I'm going to begin by saying I'm not by any means an expert- I've been using .NET with C# for about 4 months now, and basically just learning by example and docs. A game...
5
by: Steve | last post by:
newbie question. In C++ I could get a pointer to an item in a list, for example int* pInt = &myList; then I could do something like: *pInt = 666; and then myList would equal 666. Nice,...
3
by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a...
12
by: Rubbrecht Philippe | last post by:
Hi there, According to documentation I read the ArrayList.IndexOf method uses the Object.Equals method to loop through the items in its list and locate the first index of an item that returns...
9
by: Paul Nations | last post by:
I've got arraylists of simple classes bound to controls. I need to search through those arraylists to set the correct SelectedItem in the control. The code looks like: Public Class...
16
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just...
20
by: Dennis | last post by:
I use the following code for a strongly typed arraylist and it works great. However, I was wondering if this is the proper way to do it. I realize that if I want to implement sorting of the...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
3
by: Mark Jones | last post by:
I am quite new to ASP and .Net development and I am building a web-based multiple choice exam application. The web page displays the questions using a Repeater control and the answers are nested...
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.