referencing properties of objects wthin object Collections

  • Thread starter Thread starter Terry
  • Start date Start date
T

Terry

What is the syntax for referencing the properties of
objects within Collections of objects?

EXAMPLE:

Dim MCoil As New Coil
MCoil = CoilCollection("3456")
TextBox1.Text() = MCoil.CoilDesc

WANT TO BE ABLE TO AVOID INTERMEDIARY COPY (SOEMTHING
LIKE):

TextBox1.Text() = CoilCollection("3456").CoilDesc

Thanks,
Terry
 
Hi,

TextBox1.Text() = DirectCast(CoilCollection("3456"),Coil).CoilDesc

Ken
------------
 
Since you mention Collections of Objects, so I am assuming you are not using a
strongly typed collection.
I am also assuming that your problem is that the Object returned, does not know
about the CoilDesc property.
In this case, you seem fairly certain that the returned Object will be of type
Coil, so I would recommend a DirectCast.
TextBox1.Text = DirectCast(CoilCollection("3456"), Coil).CoilDesc

In a nutshell, it is doing the same thing you were doing before, but just in 1
line and a little quicker.
(note, I didn't test the above, so please forgive any typo's)

Gerald
 
Back
Top