I'm having problems with my code concerning a mulitdimensional array. Basically, I'm trying to create an array (arrTotal) which contains all of the data from 2 arrays (arrOne & arrTwo). Basically, they each contain data from Tables, and I just want to combine them into a single array which contains all of the info. Here's what I have so far, but I know something isn't right:
Dim i As Integer
Dim j As Integer
'This gives me the total upper boundaries of both arrays
ReDim arrTotal((UBound(arrOne, 1)) + (UBound(arrTwo, 1)))
'intCount2ndDimension contains the Total Number of 2nd Dimensions for
'both arrays
For j = 0 To intCount2ndDimension
'Here is where my problem is: I'm trying to fill in the data from both
'arrays into arrTotal, but I'm having problems with the multidimension
'Do I need to add both the 1st and 2nd dimensions separately or can I do it like below?:
For i = 0 To UBound(arrOne, 1)
arrTotal(i) = arrOne(i, j)
Next
'I don't think this nesting is right. I want to have arrTotal contain
'both arrOne and arrTwo:
For i = 0 To UBound(arrTwo, 1)
arrTotal(i) = arrTwo(i, j)
Next
Next
End Sub
Sorry if I wasn't clear enough. I'd appreciate any thoughts. Thanks!
4 1396
Not sure what you want.
Ary1
1
2
3
Ary2
7
8
9
Now:
Ary3(5)?
1
2
3
7
8
9
-or-
Ary3(2,1)?
1 - 7
2 - 8
3 - 9
Thanks for your reply. I think I want it to display like this:
Ary3(2,1)
1 - 7
2 - 8
3 - 9
Why would you need two loops Just try: -
For i = 0 to UBound(arrTwo, 1)
-
arrTotal(i,0) = arrOne(i)
-
arrTotal(i,1) = arrTwo(i)
-
Next
-
Try this then: - Public Class Form1
-
Dim ary1() As Integer = {1, 2, 3, 4}
-
Dim ary2() As Integer = {7, 8, 9}
-
Dim ary3(,) As Integer
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Dim x As Integer
-
Dim arySize As Integer = UBound(ary1)
-
If UBound(ary2) > arySize Then arySize = UBound(ary2)
-
ReDim ary3(arySize, 1)
-
For x = 0 To UBound(ary1)
-
ary3(x, 0) = ary1(x)
-
Next
-
For x = 0 To UBound(ary2)
-
ary3(x, 1) = ary2(x)
-
Next
-
End Sub
-
End Class
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alex Hopson |
last post by:
Hi,
I'm trying to modify a shopping cart script from Mastering PHP/MySQL and am
having trouble setting up some arrays for it. The original code, below,
stores the cart items in a session...
|
by: paul |
last post by:
Hi all,
I have a 2D array, which I am trying to access, but I am having
problems doing this:
If, for instance, I use a nested for loop to go through the values,
using something like
echo...
|
by: Charles Banas |
last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to
get some opinions and comments on it, hopefully so i can gain some
sort of insight as to why this works.
at the top of the...
|
by: Mark Smith |
last post by:
I'm trying to copy data from a 1D array to a 2D array.
The obvious thing doesn't work:
int twoDee = new int;
int oneDee = new int { 1, 2 };
Array.Copy(oneDee, 2, twoDee, 2, 2);
This causes a...
|
by: chris |
last post by:
Hi there,
I created a Multidimensional array of labels
Label lblMultiArray = new Label { {Label3, LblThuTotal},
{Label4,LblFriTotal} };
Now I would like to compare the values in the array,...
|
by: |
last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily
complicated than the other languages I know. I feel this is because there
aren't many good official resources out there to...
|
by: Nathan Sokalski |
last post by:
I have a multidimensional array declared as the following:
Dim guesses(14, 5) As Integer
I want to assign all values in a specific dimension to another array
declared as follows:
|
by: LittleCake |
last post by:
Hi All,
I have a multidimensional array where each sub-array contains just two
entries, which indicates a relationship between those two entries. for
example the first sub-array:
=Array
(
=30...
|
by: Slain |
last post by:
I need to convert a an array to a multidimensional one. Since I need
to wrok with existing code, I need to modify a declaration which looks
like this
In the .h file
int *x;
in a initialize...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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: 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...
| |