CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2003
    Location
    in the shotokan dojo
    Posts
    5

    Question a matrix problem

    Hello!!

    I need to redim an matrix that is currently composed by 1 row and 34 cols, i did this dinamically, but when i try to add an row to the matrix i get an error...

    the size is 1,34 but i need to increment the rows indefinitely... how can i do this??


    sorry by my poor english!!


    any idea would be useful...

  2. #2
    Join Date
    Jan 2003
    Location
    North Carolina
    Posts
    309
    Keep in mind when you intially Dim the variable object it must be with empty parentheses. Then you can set the size with ReDim.

    From MSDN Library

    The ReDim statement is used to size or resize a dynamic array that has already been formally declared using a Private, Public, or Dim statement with empty parentheses (without dimension subscripts). You can use the ReDim statement repeatedly to change the number of elements and dimensions in an array.
    Example

    Code:
    <SCRIPT LANGUAGE='VBSCRIPT'>
    dim x()
    
    growx(1)
    
    function growx(newrowsize)
    	ReDim x(newrowsize, 34)
    end function
    </SCRIPT>
    
    <input type=button name=xxx onclick='growx(2)' value=test>

  3. #3
    Join Date
    Feb 2003
    Location
    in the shotokan dojo
    Posts
    5
    I do this but i get this error

    Microsoft VBScript runtime error '800a0009'

    Subscript out of range



    this error is in the line where i have this code...


    redim preserve matrix(newMaxRows,34)


    when i print the maxrows before the redim it give to me 0


    mmm... any idea??

  4. #4
    Join Date
    Jan 2003
    Location
    North Carolina
    Posts
    309
    Can you please post your code details so I can see how you are defining and setting your values, plus the method by which you are calling the resize and set?

  5. #5
    Join Date
    Feb 2003
    Location
    in the shotokan dojo
    Posts
    5
    Thanks for the help... i read an article in msdn that explains that a matrix can be redimmed only in the second dimension that is i can add cols indefinitely but i can't add rows indefinitely... I try another way to solve my problem and it works fine... thanks!!

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

Featured