I'm trying to create an array of objects in vbscript, where each object has a string and a number as properties. The string is coming from a different array, and the number is incremented in the loop.
Here's the error occurring, on the line
newValues(i) = (New Pet)(values(i), number):
...and here's my code:
Class Pet
Public objectName
Public objectNumber
' constructor here:
Public Default Function Init(name, number)
objectName = name
objectNumber = number
Set Init = Me
End Function
End Class
values = Array(_
"Cat",_
"Dog",_
"Bird"_
)
number = 3
ReDim newValues(uBound(values))
For i = 0 to uBound(values)
newValues(i) = (New Pet)(values(i), number)
number = number + 1
Next
Setwhen assigning objects.Set newValues(i) = (New Pet)(values(i), number)