|
-
February 17th, 2003, 03:07 PM
#1
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...
-
February 18th, 2003, 05:58 AM
#2
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>
-
February 18th, 2003, 07:23 AM
#3
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??
-
February 18th, 2003, 08:40 AM
#4
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?
-
February 18th, 2003, 09:32 AM
#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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|