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

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

    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. #2
  3. 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
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    california usa
    Posts
    353
    Rep Power
    18
    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.
  6. #4
  7. Inherits Programmer.Slacker
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Aug 2003
    Location
    Between my Id and your Ego
    Posts
    2,351
    Rep Power
    725
    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
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    32
    Rep Power
    11
    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
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2003
    Posts
    1,152
    Rep Power
    13
    Yes,Unkie's answer is Creative!
  12. #7
  13. Inherits Programmer.Slacker
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Aug 2003
    Location
    Between my Id and your Ego
    Posts
    2,351
    Rep Power
    725
    interesting solution - good job Unkie!
    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
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Andorra
    Posts
    5
    Rep Power
    0

    hello


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

    Join Date
    Nov 2012
    Location
    Andorra
    Posts
    5
    Rep Power
    0

    hello


    hello

IMN logo majestic logo threadwatch logo seochat tools logo