### Thread: Array() Function, 2 Dimensional Array

1. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2003
Location
california usa
Posts
353
Rep Power
19

#### Array() Function, 2 Dimensional Array

I cant figure out how to use the array function to initialize a 2 dimensional array.

i have a basic 9x9 list i need in an array

Its for an assignment and the teacher said dont use Form_Load methods where you assign each subscript a value, but to use the array function. simple for one dimension but i cant figure it out for two.

VB says
"Array(ParamArray ArgList() As Variant)"

2. No Profile Picture
Contributing User
Devshed Beginner (1000 - 1499 posts)

Join Date
Jul 2003
Posts
1,152
Rep Power
13
if u will define a 2 dimensional array,u can do it:
dim arglist(1 to 9,1 to 9) as integer
When u will assign to the member of this array,u can do it:
arglist(x,y)=z
x:1st dimensional member's number
y:2th dimensional member's number
z:assign value
3. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2003
Location
california usa
Posts
353
Rep Power
19
i know how to assign to a 2d array using that method, but that would require 80 lines of code since im hard coding a static table of information. the teacher specifically said not to do it that way and use the Array() function to insert the data.
i know for a 1d array its
intArr = Array(x, x, x, x, x)
but for a 2d i cant figure it out.
4. who told you to do it this way? Are you supposed to assign the entire array at once, or can you do it a subscript at a time? The reason I ask is, I don't know any way to do what you're proposing. If you find out, please post it.
5. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2003
Posts
32
Rep Power
12

Dim arglist(9) As Variant

arglist(0) = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
arglist(1) = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
arglist(2) = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
arglist(3) = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
arglist(4) = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
arglist(5) = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
arglist(6) = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
arglist(7) = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
arglist(8) = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
For i = 0 To 8
For j = 0 To 8
MsgBox arglist(i)(j) + arglist(i)(j) 'proof of being integer as type

Next j
Next i
6. No Profile Picture
Contributing User
Devshed Beginner (1000 - 1499 posts)

Join Date
Jul 2003
Posts
1,152
Rep Power
13
7. interesting solution - good job Unkie!
8. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Location
Andorra
Posts
5
Rep Power
0

#### hello

hello
9. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Location
Andorra
Posts
5
Rep Power
0

hello