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'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top