Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Array of objects

Hi, can i do something like this?

In a module which i store all the global variables, i declare

public obj() as someClass

and on pageload based on a number generated.

for i = 0 to int_generated - 1
    obj(i) = new someClass
next

Thanks
0
jaxrpc
Asked:
jaxrpc
1 Solution
 
omegaomegaDeveloperCommented:
Hello, jaxrpc,

Yes, but you will need to re-dimension the array before you assign to it.  Use:

        ReDim obj(int_generated)
        For i As Integer = 0 To int_generated - 1
            obj(i) = New someClass
        Next i

Cheers,
Randy
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now