Array of Objects

  • Thread starter Thread starter JF
  • Start date Start date
J

JF

Trying to create a variable array of SMS collection rules:

Dim aRules() as Array, Dim oRule as Object
Index = 0

sub proceedure
oRule.XXX
oRule.XXX

ReDim Preserve aRules(i)
aRules(i) = oRule (error here!!!)
i=i+1

Error: InvalidCastException "Specified cast is not Valid"
Works in vbscript.
 
JF said:
Trying to create a variable array of SMS collection rules:

Dim aRules() as Array, Dim oRule as Object
Index = 0

sub proceedure
oRule.XXX
oRule.XXX

ReDim Preserve aRules(i)

This creates an array of arrays, not an array of objects. Use

dim arules() as object 'or dim arules as object()

ReDim Preserve aRules(i)

instead.
 
* "JF said:
Trying to create a variable array of SMS collection rules:

Dim aRules() as Array, Dim oRule as Object
Index = 0

sub proceedure
oRule.XXX
oRule.XXX

ReDim Preserve aRules(i)
aRules(i) = oRule (error here!!!)
i=i+1

Error: InvalidCastException "Specified cast is not Valid"
Works in vbscript.

You are creating an /array/ of /'Array' objects/. Change the dim of
'aRules' to this: 'Dim aRules() As Object'.
 
Back
Top