|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
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)" Help please ![]() |
|
#2
|
|||
|
|||
|
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
|
|||
|
|||
|
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.
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#5
|
|||
|
|||
|
here's your solution, drew
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
|
|||
|
|||
|
Yes,Unkie's answer is Creative!
|
|
#7
|
||||
|
||||
|
interesting solution - good job Unkie!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Array() Function, 2 Dimensional Array |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|