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

Adding two different object arrays

I have created two different object arraylist of n size. Once my first arraylist is full and no number are unique i will test again this time putting the second test values in arraylist 2. how can i then take the results in my arraylist1 and arraylist2 add each of the indexs and average them out.

arraylist1 (0) 400
(1) 401
(2) 402

arraylist2 (0) 399
(1) 400
(2) 401

then add arraylist1 + arraylist2 / number of arraylist = avgarraylist


can anyone help me out. I thought about a for each loop however that not working.
Oct 26 '07 #1
4 1494
QVeen72
1,445 Expert 1GB
Hi,

This may work:

Expand|Select|Wrap|Line Numbers
  1. Dim i As Long
  2. For i = LBound(ArrList1) To UBound(ArrList1)
  3.    ArrList3(i) = (Arrlist1(i) + ArrList2(i)) / 2
  4. Next
  5.  
Just Check both of the Arrays, Should Have Same Higher and Lower Bound..
If not, then you can put a "If" Condition in the Loop...

Regards
Veena
Oct 26 '07 #2
kadghar
1,295 Expert 1GB
I have created two different object arraylist of n size. Once my first arraylist is full and no number are unique i will test again this time putting the second test values in arraylist 2. how can i then take the results in my arraylist1 and arraylist2 add each of the indexs and average them out.

arraylist1 (0) 400
(1) 401
(2) 402

arraylist2 (0) 399
(1) 400
(2) 401

then add arraylist1 + arraylist2 / number of arraylist = avgarraylist


can anyone help me out. I thought about a for each loop however that not working.
i think a FOR or a LOOP actualy will do, try something like

Expand|Select|Wrap|Line Numbers
  1. dim i as integer
  2. for i = 0 to ubound(arraylist1)
  3.     avgarraylist(i) = (arraylist1(i)+arraylist2(i)) / 2
  4. next
HTH

**Sorry Veena, i didnt see you've already answered.
Oct 26 '07 #3
i think a FOR or a LOOP actualy will do, try something like

Expand|Select|Wrap|Line Numbers
  1. dim i as integer
  2. for i = 0 to ubound(arraylist1)
  3.     avgarraylist(i) = (arraylist1(i)+arraylist2(i)) / 2
  4. next
HTH

**Sorry Veena, i didnt see you've already answered.
[code]
Dim AVGarraylist As New ArrayList
Dim intloop1 As Long
For intloop1 = LBound(_ArrayList1) To UBound(_Arraylist2)
AVGarraylist(intloop1) = (_ArrayList1(intloop1) + _Arraylist2(intloop1)) / 2
Next

/[code]

it give me an error message system.collection.arraylist can not be converted to system.array
Oct 26 '07 #4
kadghar
1,295 Expert 1GB
it give me an error message system.collection.arraylist can not be converted to system.array
try defining it with:
dim AVGarraylist() as double
redim AVGarraylist(ubound(arraylist1))

HTH
Oct 26 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: David | last post by:
I have an array that contains numbers in string elements , i want to convert this to integers, i have made a for loop that uses the number of elements in the array and then adds 0, thereby...
4
by: John MacIntyre | last post by:
Hi, I have a page with a series of child pages loaded into an iframe. When I move from page to page, I store an object containing the child's control data in a variable on the main page, then...
34
by: Adam Hartshorne | last post by:
Hi All, I have the following problem, and I would be extremely grateful if somebody would be kind enough to suggest an efficient solution to it. I create an instance of a Class A, and...
3
by: Marco | last post by:
Hello there, We're new to C# and have noticed a strange behaviour which we don't yet understand. We wrote a COM DLL (in VC++ 6.0) which performs some calculation based on some double arrays...
5
by: Troy | last post by:
Hello, I have a dumb question. I have two array objects of type double with 12 elements in each object. I'd like to add the two objects but dont know how to. Any ideas? thanks
47
by: Pierre Barbier de Reuille | last post by:
Please, note that I am entirely open for every points on this proposal (which I do not dare yet to call PEP). Abstract ======== This proposal suggests to add symbols into Python. Symbols...
47
by: Albert | last post by:
So structures are useful to group variables, so you can to refer to a collection as a single entity. Wouldn't it be useful to also have the ability to collect variable and functions? Ask K&R...
6
by: santiago | last post by:
I guess one cannot do this: arraytot = arraytot + arraydet; So, what's the trick to adding arrays like this? Thanks.
4
by: ndedhia1 | last post by:
I am reading in a file to see what delays I am getting on what IP address: QuoteBlockTiming exceeded 1000 ms: 1684 --- Fri Nov 06 06:09:10 CST 2009 170.137.94.95 Class key = 649126730 block...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.