Dynamic Object 
Author Message
 Dynamic Object

In VB.Net:

Let's say I have 10 objects - named Object1,
Object2, .... Object10

I have a procedure that takes a number as an argument.  
Depending on this number, I want to operate on a
different object.

For instance, argument = 4 then I need Object 4.

Instead of one huge select case statement, I'd like to do
something like this-

MyObject = Eval("Object" + argument)

Which is what I would do with ASP - but I don't know how
to do it in VB.Net

Thank you in advance for your help!



Thu, 24 Feb 2005 02:48:17 GMT  
 Dynamic Object
hey if u have all your objects in an array u can just get the desired object
by
yourobj = yourobjarray(passednnum)

whats the problem? I mean why do u want to have 10 diff variables when u can
have one variable array to access all of those. I think u r not using arrays
where they should be used.


Quote:

> In VB.Net:

> Let's say I have 10 objects - named Object1,
> Object2, .... Object10

> I have a procedure that takes a number as an argument.
> Depending on this number, I want to operate on a
> different object.

> For instance, argument = 4 then I need Object 4.

> Instead of one huge select case statement, I'd like to do
> something like this-

> MyObject = Eval("Object" + argument)

> Which is what I would do with ASP - but I don't know how
> to do it in VB.Net

> Thank you in advance for your help!



Thu, 24 Feb 2005 04:01:47 GMT  
 Dynamic Object

Thanks for your help...
The idea of arrays had occurred to me, but I was trying
to find the VB equivalent of "Eval" to save me some lines
of code.

Quote:
>-----Original Message-----
>hey if u have all your objects in an array u can just

get the desired object
Quote:
>by
>yourobj = yourobjarray(passednnum)

>whats the problem? I mean why do u want to have 10 diff

variables when u can
Quote:
>have one variable array to access all of those. I think

u r not using arrays
Quote:
>where they should be used.



>> In VB.Net:

>> Let's say I have 10 objects - named Object1,
>> Object2, .... Object10

>> I have a procedure that takes a number as an argument.
>> Depending on this number, I want to operate on a
>> different object.

>> For instance, argument = 4 then I need Object 4.

>> Instead of one huge select case statement, I'd like to
do
>> something like this-

>> MyObject = Eval("Object" + argument)

>> Which is what I would do with ASP - but I don't know
how
>> to do it in VB.Net

>> Thank you in advance for your help!

>.



Thu, 24 Feb 2005 03:52:35 GMT  
 Dynamic Object
You may also want to look at collections, as there are autosizing and have
some other useful feature snot found in arrays.

Bob


Quote:

> In VB.Net:

> Let's say I have 10 objects - named Object1,
> Object2, .... Object10

> I have a procedure that takes a number as an argument.
> Depending on this number, I want to operate on a
> different object.

> For instance, argument = 4 then I need Object 4.

> Instead of one huge select case statement, I'd like to do
> something like this-

> MyObject = Eval("Object" + argument)

> Which is what I would do with ASP - but I don't know how
> to do it in VB.Net

> Thank you in advance for your help!



Thu, 24 Feb 2005 08:09:08 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Dynamic Objects with VB.net

2. Dynamic Objects in VBS

3. ****----DYNAMIC OBJECT MODELING --------******

4. dynamic object creation in VB4

5. Create Dynamic Objects

6. Dynamic Object creation

7. Dynamic Object Calls

8. VB 4.0 Events on dynamic objects???

9. Dynamic object creation at run-time...

10. Dynamic object creation at run-time...

11. Dynamic object creation license

12. Event Capture from Dynamic Objects

 

 
Powered by phpBB® Forum Software