473,320 Members | 2,020 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,320 software developers and data experts.

Add Arraylist to Arraylist

rdi
I have 3 classes:

mailBox, mailFilter & mailFilterSet

I then have an arraylist. Each element in the array is of type mailBox (variable name is mbox). One item of the mailbox class is an arraylist named filterSet. The intended purpose is for this arrayList to contain type mailFilterSet elements. The mailFilterSet class contains a string (the name of the filter set) and an arraylist--which is intened to contain mailFilter elements.

'This works fine <= Create the mbox in array position 1.
dim i as integer = 0
mbox.Add(New mailbox())

'Then when I try to create the first element in the filter set array, it fails and gives
'an unhandled exception of type 'system.NullReferenceException".
'Additional variable or With block variable not set.
mbox.(i).filterSet.add(new mailFilterSet)

The class definitions are below.

TIA

Public Class mailbox
Public mbox As String
Public acct As String
Public fromName As String
Public fromAddress As String
Public replyAddress As String
Public ReplyMessage As String
Public ReplyAttach As String
Public sender As String
Public forwardAddress As String
Public forwardMessage As String
Public forwardAttach As String
Public sendReply As Boolean = False
Public sendForward As Boolean = False
Public replyIncludeOriginal As Boolean = True
Public forwardIncludeOriginal As Boolean = True

'0 = As Attachment
'1 = In Brackets
'2 = Unchanged
Public replyIncludeOriginalMethod As Integer = 0

Public forwardIncludeOriginalMethod As Integer = 0
Public filterSet As ArrayList
End Class

Public Class mailFilterSet
Public filterName As String
Public filter As ArrayList
End Class

Public Class mailFilter
'andor:
'2 = n/a
'1 = And
'0 = Or
Public andor As Integer
'field:
'0 = To:
'1 = From:
'2 = Reply:
'3 = Subject
'4 = Message
Public field As Integer
'TYPE:
' 0 => = <= Equal
'1 => != <= Not Equal
'2 => *= <= Ends With
'3 => =* <= Begins With
'4 => *=* <= Contains
'5 => !*=* <= Doesn't Contain
Public type As Integer
Public content As String
End Class
--

RDI

(remove the exclamation from the email address)

Nov 20 '05 #1
5 1667
"rdi" <rd**@writeme.com> schrieb
I have 3 classes:

mailBox, mailFilter & mailFilterSet

I then have an arraylist. Each element in the array is of type
In the array or in the arraylist?
mailBox (variable name is mbox). One item of the mailbox class is an
arraylist named filterSet. The intended purpose is for this
arrayList to contain type mailFilterSet elements. The mailFilterSet
class contains a string (the name of the filter set) and an
arraylist--which is intened to contain mailFilter elements.

'This works fine <= Create the mbox in array position 1.
dim i as integer = 0
mbox.Add(New mailbox())

'Then when I try to create the first element in the filter set array,
it fails and gives 'an unhandled exception of type
'system.NullReferenceException". 'Additional variable or With block
variable not set.
mbox.(i).filterSet.add(new mailFilterSet)

^
Is here really a dot?

First, I'd split the line to find the error (maybe wrong types name but you
see the point):

dim mb as mailbox
dim fs as mailfilter
dim mfs as mailfilterset

mb = mbox(i)
fs = mb.filterset
mfs = new mailfilterset
fs.add(mfs)
I guess, you only declared mbox, but didn't assign an array (use Redim for
this). Or, the filterset property returns Nothing, which means, that you
didn't create an Arraylist (use the New keyword) in the mailbox class and/or
didn't assign it to the private field returned by the filterset property.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
rdi
Armin,

Thanks.

1) When I couldn't find my message last night, I thought it didn't get posted for some reason. So I reposted it.
2) After I posted it again, I kept working. I realized the problem--it was that pesky NEW statement.
3) as far as the typos you found go, the previous post wasn't a TOTAL copy/paste. I tried to clean it up a little to make it easier to read.
The result:

Public Class mailbox
'a buch of string and integer variables

'here's the arraylist I'm concerned with
public filterSet as NEW arraylist '<=I didn't have the NEW before
end class
public class mailFilterSet
public filterName as string

'and this arraylist too
public filter as NEW arraylist '<=I didn't have the NEW before either
end class
public class mailFilter
'a buch of string and integer variables
end class
Public mbox as new arraylist
sub main ()
dim i, j, k as integer
for i = 0 to upperLimit
mbox.add(new mailBox)
'set the other variables
for j = 0 to upperLimit
mbox(i).filterSet.add(new mailFilterSet)
mbox(i).filterSet(j).filterName = filterName
for k = 0 to upperLimit
mbox(i).filterSet(j).filter.add(new mailFilter)
'set all the varialbles in this filter
Next
Next
Next
end sub
mbox(1)
integer variables
string variables
mailFilterSet(1)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)
mailFilterSet(2)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)
mailFilter(4)
mailFilterSet(2)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)
mailFilter(4)
mbox(2)
integer variables
string variables
mailFilterSet(1)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)
mailFilterSet(2)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)
mailFilter(4)
mailFilterSet(2)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)

--

RDI

(remove the exclamation from the email address)

"Armin Zingler" <az*******@freenet.de> wrote in message news:40***********************@news.freenet.de...
"rdi" <rd**@writeme.com> schrieb
I have 3 classes:

mailBox, mailFilter & mailFilterSet

I then have an arraylist. Each element in the array is of type


In the array or in the arraylist?
mailBox (variable name is mbox). One item of the mailbox class is an
arraylist named filterSet. The intended purpose is for this
arrayList to contain type mailFilterSet elements. The mailFilterSet
class contains a string (the name of the filter set) and an
arraylist--which is intened to contain mailFilter elements.

'This works fine <= Create the mbox in array position 1.
dim i as integer = 0
mbox.Add(New mailbox())

'Then when I try to create the first element in the filter set array,
it fails and gives 'an unhandled exception of type
'system.NullReferenceException". 'Additional variable or With block
variable not set.
mbox.(i).filterSet.add(new mailFilterSet)

^
Is here really a dot?

First, I'd split the line to find the error (maybe wrong types name but you
see the point):

dim mb as mailbox
dim fs as mailfilter
dim mfs as mailfilterset

mb = mbox(i)
fs = mb.filterset
mfs = new mailfilterset
fs.add(mfs)


I guess, you only declared mbox, but didn't assign an array (use Redim for
this). Or, the filterset property returns Nothing, which means, that you
didn't create an Arraylist (use the New keyword) in the mailbox class and/or
didn't assign it to the private field returned by the filterset property.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
rdi
Armin,

Thanks.

1) When I couldn't find my message last night, I thought it didn't get posted for some reason. So I reposted it.
2) After I posted it again, I kept working. I realized the problem--it was that pesky NEW statement.
3) as far as the typos you found go, the previous post wasn't a TOTAL copy/paste. I tried to clean it up a little to make it easier to read.
The result:

Public Class mailbox
'a buch of string and integer variables

'here's the arraylist I'm concerned with
public filterSet as NEW arraylist '<=I didn't have the NEW before
end class
public class mailFilterSet
public filterName as string

'and this arraylist too
public filter as NEW arraylist '<=I didn't have the NEW before either
end class
public class mailFilter
'a buch of string and integer variables
end class
Public mbox as new arraylist
sub main ()
dim i, j, k as integer
for i = 0 to upperLimit
mbox.add(new mailBox)
'set the other variables
for j = 0 to upperLimit
mbox(i).filterSet.add(new mailFilterSet)
mbox(i).filterSet(j).filterName = filterName
for k = 0 to upperLimit
mbox(i).filterSet(j).filter.add(new mailFilter)
'set all the varialbles in this filter
Next
Next
Next
end sub
mbox(1)
integer variables
string variables
mailFilterSet(1)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)
mailFilterSet(2)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)
mailFilter(4)
mailFilterSet(2)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)
mailFilter(4)
mbox(2)
integer variables
string variables
mailFilterSet(1)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)
mailFilterSet(2)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)
mailFilter(4)
mailFilterSet(2)
filterName
mailFilter(1)
mailFilter(2)
mailFilter(3)

--

RDI

(remove the exclamation from the email address)

"Armin Zingler" <az*******@freenet.de> wrote in message news:40***********************@news.freenet.de...
"rdi" <rd**@writeme.com> schrieb
I have 3 classes:

mailBox, mailFilter & mailFilterSet

I then have an arraylist. Each element in the array is of type


In the array or in the arraylist?
mailBox (variable name is mbox). One item of the mailbox class is an
arraylist named filterSet. The intended purpose is for this
arrayList to contain type mailFilterSet elements. The mailFilterSet
class contains a string (the name of the filter set) and an
arraylist--which is intened to contain mailFilter elements.

'This works fine <= Create the mbox in array position 1.
dim i as integer = 0
mbox.Add(New mailbox())

'Then when I try to create the first element in the filter set array,
it fails and gives 'an unhandled exception of type
'system.NullReferenceException". 'Additional variable or With block
variable not set.
mbox.(i).filterSet.add(new mailFilterSet)

^
Is here really a dot?

First, I'd split the line to find the error (maybe wrong types name but you
see the point):

dim mb as mailbox
dim fs as mailfilter
dim mfs as mailfilterset

mb = mbox(i)
fs = mb.filterset
mfs = new mailfilterset
fs.add(mfs)


I guess, you only declared mbox, but didn't assign an array (use Redim for
this). Or, the filterset property returns Nothing, which means, that you
didn't create an Arraylist (use the New keyword) in the mailbox class and/or
didn't assign it to the private field returned by the filterset property.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
"rdi" <rd**@writeme.com> schrieb
Armin,

Thanks.

1) When I couldn't find my message last night, I thought it didn't get
posted for some reason. So I reposted it. 2) After I posted it again,
I kept working. I realized the problem--it was that pesky NEW
statement.


Found the second post after writing the reply. :-( ;)
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
"rdi" <rd**@writeme.com> schrieb
Armin,

Thanks.

1) When I couldn't find my message last night, I thought it didn't get
posted for some reason. So I reposted it. 2) After I posted it again,
I kept working. I realized the problem--it was that pesky NEW
statement.


Found the second post after writing the reply. :-( ;)
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6

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

Similar topics

7
by: Alex Ting | last post by:
Hi Everybody, I have an issue about deleting an object from an arrayList. I've bounded a datagrid using this code where it will first run through all of the code in loadQuestions() and bind a...
3
by: george r smith | last post by:
I am trying to create an arrayList that contains multiple arrayLists. My code attempt is below. The question I have is how can I get away from creating another pAttribute list than can be added to...
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...
6
by: gane kol | last post by:
Hi, I have a code that creates a datatable from an arraylist, but i am getting an error in casting in for (int intRow = 0; intRow < alLCPlist.Count; intRow++) { DataRow drow =...
4
by: Peter | last post by:
I run into this situation all the time and I'm wondering what is the most efficient way to handle this issue: I'll be pulling data out of a data source and want to load the data into an array so...
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...
18
by: Sam | last post by:
Hi All I'm planing to write an application which allows users dynamically add their points (say you can add upto 30,000) and then draw xy graph. Should I use an array for my coordinate point...
6
by: fniles | last post by:
I am using VB.NET 2003 and a socket control to receive and sending data to clients. As I receive data in 1 thread, I put it into an arraylist, and then I remove the data from arraylist and send it...
3
by: Christopher H | last post by:
I've been reading about how C# passes ArrayLists as reference and Structs as value, but I still can't get my program to work like I want it to. Simple example: ...
1
by: =?Utf-8?B?SkI=?= | last post by:
Hello My pgm1 (User Interface Level) passes an empty ArrayList to pgm2 (Business Logic Level). pgm2 then calls pgm3 (Data Access Level) to populate the ArrayList. Question1: When pgm2 gets...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.