Results 1 to 4 of 4

Thread: create an aray on the fly

  1. #1

    Thread Starter
    Addicted Member Rudy's Avatar
    Join Date
    Sep 2000
    Location
    BC, Canada
    Posts
    198

    create an aray on the fly

    im building a directX program that will load a map in memory, i want to be able to store if in a 3D array ( eg: map(x,y,z) ) but i dont know the size of the array untill i read the map file

    here's the possible dimmensions

    10 <= X <= 255
    10 <= Y <= 255
    1 <= Z <= 3
    *Rudy^
    Visual Studio 6 Ent. SP5
    Windows 2000 SP4
    Windows XP SP1a

  2. #2
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456

    Re: create an aray on the fly

    Originally posted by Rudy
    im building a directX program that will load a map in memory, i want to be able to store if in a 3D array ( eg: map(x,y,z) ) but i dont know the size of the array untill i read the map file

    here's the possible dimmensions

    10 <= X <= 255
    10 <= Y <= 255
    1 <= Z <= 3
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4. Dim l_strArray() As String
    5.  
    6.     ReDim l_strArray(0)
    7.     l_strArray(UBound(l_strArray)) = "First Element"
    8.    
    9.     ReDim Preserve l_strArray(UBound(l_strArray) + 1)
    10.     l_strArray(UBound(l_strArray)) = "Second Element"
    11.    
    12.     ReDim Preserve l_strArray(UBound(l_strArray) + 1)
    13.     l_strArray(UBound(l_strArray)) = "Nth Element"
    14.    
    15. Dim i As Integer
    16.    
    17.     For i = LBound(l_strArray) To UBound(l_strArray)
    18.         MsgBox l_strArray(i)
    19.     Next
    20. End Sub

    This should give you enough idea !!!

  3. #3

    Thread Starter
    Addicted Member Rudy's Avatar
    Join Date
    Sep 2000
    Location
    BC, Canada
    Posts
    198
    this works only on a 1D array

    you cant do it with a 3D array
    *Rudy^
    Visual Studio 6 Ent. SP5
    Windows 2000 SP4
    Windows XP SP1a

  4. #4
    Fanatic Member
    Join Date
    Feb 2003
    Location
    Los Angeles, CA
    Posts
    681
    true. on a multi-dimensional array you can only redim the last dimension of the array. i would suggest using arrays of UDT's if possible.
    there are 2 reasons why i leave my work unfinished:
    (1) i'm getting old.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width