Hi David,
If you are assigning a numerical value you must use the property or
method assignment inside the object or you are assigning numbers to an
object and that is the error.
You can not in .VBS do anything immediate and you have to do a loop for
all assignments. Unless you do the assignment inside brackets for an array,
but you are using objects, so you have to make an object assignment there,
V1.val....
The other way is to have a new assignment inside the class which does
create an object and that object gets put in the array.
But doing that you still have to copy each element over one at a time...
Bruce
Sent: Sunday, April 29, 2012 9:33 PM
Subject: Object Assignment
Hello,
I am studying (and hopefully learning something,) VB Scripting and
I'm currently learning about classes. I have a class with private
variables V1(99) and V2(99). Within the Class_Initialize SUB
routine, I initialize V1 to its correct values. (Each element in the
array is an object. Each object is defined and assigned. I have
verified its correctness.
Now, at the end of Class_Initialize, Ihave the statement:
V2 = V1 ' line alpha
set V2 = V1 ' line beta
It loads fine with no load errors. However, at run time, Iget the
error: line alpha ... type mismatch
and also:
line beta type mismatch.
Both V1 and V2 on on sequential lines -- that is, they are not
separated by anything, not even a blank line -- no routines, no
declarations -- nothing.
So, how do I copy an object containing objects within the class'
declarative scope? Since these are arrays of 99 objects, do I need to
run a loop to explicitly copy each object element from V1 to its
corresponding location in V2? Is there no aggregate copy?
Class Aggregate
private V1(99) ' Cannot use the constant named AgSize. So much for
using constants!
private V2(99)
...
sub Class_Initialize ()
...
for I = 1 to AgSize
set V1(I) = new AggregateElementObject
next
V2 = V1 ' line alpha and also tried
set V2 = V1 ' get the same type mismatch error
...
end Class ' Aggregate
Thanks for any help with this.
Dave