
November 9th, 2003, 10:46 PM
|
|
Junior Member
|
|
Join Date: Nov 2003
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Cannot redim a array inside a class
My Problem is I have a custom class that has an dynamic array inside of it. I also need to have an array of these classes with arrays in them (all dynamic). The problem is MS VBScript appears to not understand the object when using the DIM statement.
Example 1)
Code:
class clsMyTest
dim strTitle
dim arrClassTest()
end class
' M Y C L A S S I N A N A R R A Y
dim arrMyTest()
for i = 0 to 3
redim preserve arrMyTest(i)
set arrMyTest = new clsMyTest
arrMyTest(i).strTitle = "Boo"
for j = 0 to 1
redim preserve arrMyTest(i).arrClassTest(j)
mytest(i).arrClassTest(j) = "Hoo"
response.write arrMyTest(i).arrClassTest(j)
next
response.write arrMyTest(i).strTitle
next
Results:
Code:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/untitled.asp, line 15
redim preserve arrMyTest(i).arrClassTest(j)
---------------------------^
Example 2)
Code:
class clsMyTest
dim strTitle
dim arrClassTest()
end class
dim myTest
set myTest = new clsMyTest
myTest.strTitle = "Boo"
response.write myTest.strTitle
for j = 0 to 1
redim preserve mytest.arrClassTest(j)
myTest.arrClassTest(j) = "Hoo"
response.write myTest.arrClassTest(j)
next
Results:
Code:
Microsoft VBScript compilation error '800a03ed'
Expected '('
/untitled.asp, line 29
redim preserve mytest.arrClassTest(j)
---------------------^
Any ideas on how to get VBScript to like this idea? I have tryed using the With Statement eg.
Code:
With myTest
Redim Preserve .arrMyTest(j)
End With
but fails expecting an object! Grr....
Hope you can help me!
Regards,
Michael Proctor
|