
Arrays dim'd at class scope get type mismatch
Cheers Michael,
Thought I was going nuts - couldn't find such documentation anywhere.
I reckon in VB6 most of my classes contain array type data as this type of
complex data benefits lots from oo. Seems a real drawback to using classes
in VBScript.
In the end I used a Script Component.
Regards,
Mark Hatfield.
This is a known "limitation" in the current implementation of VBScript
classes. You can only Dim simple variants at "class level", even though no
error is thrown when you Dim foo(), Dim foo(99), or Const bar = "bar" at
"class level".
This has _not_ changed in the version 5.5 beta1.
--
Michael Harris
MVP - Windows Script
I had the same problem, and I still don't understand why. Try this
Class CTest
Dim somearray()
Private Sub Class_Initialize
ReDim somearray(0)
somearray(0) = Null
'or Set somearray(0) = Nothing
End Sub
End Class
What am I doing wrong with vbscript 5.1?!
If I declare a class with an array DIM'd at the beginning, the subs within
the class get a type mismatch when they try to access the array.
Don't get the error if I define the array within the sub, but this is
useless for me, as I need class scope for the array.
Regards,
Mark Hatfield