Click to See Complete Forum and Search --> : a matrix problem
evil_ryu
February 17th, 2003, 02:07 PM
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...
antares686
February 18th, 2003, 04:58 AM
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 (http://msdn.microsoft.com) 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
<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>
evil_ryu
February 18th, 2003, 06:23 AM
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??:(
antares686
February 18th, 2003, 07:40 AM
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?
evil_ryu
February 18th, 2003, 08:32 AM
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!!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.