By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

Combine (2) Arrays into a Single Average Array

P: 25
I know have (2) seperate arrays that hold an undefined number of information. I would like to take array-1 and array-2 and create an average array between the two


array1 array2 arrayAVG
4096 4095 4095.5
4071 4012 4041.5
4000 3812 3906


This would be the idea of how i wnat it, then i would take the arrayAVG and write to a file.
Sep 6 '07 #1
Share this Question
Share on Google+
2 Replies


kadghar
Expert 100+
P: 1,295
just create it
if array1 and array2 have the same number of elements and the same indexes, something like this will help:

Expand|Select|Wrap|Line Numbers
  1. dim i as integer
  2. dim arrayAV() as double
  3.  
  4. redim arrayAV(lbound(array1) to ubound(array1))
  5.  
  6. for i = lbound(array1) to ubound(array1)
  7.     arrayAV(i)= (array1(i) + array2(i) )/2
  8. next
hth
Sep 6 '07 #2

P: 73
Hi,

I created a sample program for you that might help you combine two or more arrays in 1 single array.. you can use this program as a pattern.

Dim x1(2) As String
Dim x2(2) As String
Dim x3(2) As String
Dim i As Integer = 0

For i = 0 To 2
x1(i) = "FName_" & i
x2(i) = "MName_" & i
x3(i) = "LName_" & i
Next

Dim xCombined(8) As String
x1.CopyTo(xCombined, 0)
x2.CopyTo(xCombined, 3)
x3.CopyTo(xCombined, 6)






I know have (2) seperate arrays that hold an undefined number of information. I would like to take array-1 and array-2 and create an average array between the two


array1 array2 arrayAVG
4096 4095 4095.5
4071 4012 4041.5
4000 3812 3906


This would be the idea of how i wnat it, then i would take the arrayAVG and write to a file.
Sep 7 '07 #3

Post your reply

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