[dba-VB] Iterating class properties

Drew Wutka DWUTKA at Marlow.com
Tue Nov 13 14:13:50 CST 2007


Ummmmm, not what I was saying.

In VB 6, with my classes property, I can go:

Wd.Height or wd.Properties("Height")

Drew

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Eric Barro
Sent: Tuesday, November 13, 2007 12:53 PM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] Iterating class properties

.NET handles this well Drew.

In VB

Dim wd as Widget = New Widget()

Wd.Height = 10

In C#

Widet wd = new Widget();

Wd.Height = 10;

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Drew Wutka
Sent: Tuesday, November 13, 2007 8:55 AM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] Iterating class properties

What are you trying to accomplish?  I don't use .Net very often, still
do
most of my stuff in VB 6.  But I wanted a way to dynamically capture my
class properties.

For example, let's say I had Widget, and it had Height and Width
properties.
I wanted to be able to do this:

Dim wd as Widget
Set wd=new Widget
Wd.Properties("Height")=10

Or

Dim wd as Widget
Dim I as long
Set wd=new Widget
For i=1 to wd.Properties.Count
	Wd.Properties(i)=15
Next i

I don't know if .Net has this capability, VB 6 didn't natively, but I
was
able to 'spoof' the ability.  I created an Add-in that let's me create a
Properties property for a class.  When you run the Add-in, it goes
through
all of the properties in your class, and creates statements to simulate
the
abilities above.  It's adding a lot of extra code to do this, but in
some
situations I have run into, it's worth it...plus, all the properties are
left alone, so I can use them like I normally would.

Drew

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Tuesday, November 13, 2007 6:43 AM
To: dba-vb at databaseadvisors.com
Subject: [dba-VB] Iterating class properties

Does anyone know a way to iterate the properties of a class in VB.Net or
C#.Net (or in .Net in general)?  There is built-in functionality to
store
classes out to XML files and this stuff does exactly that, apparently
using
only the Get/Let statements, i.e. if there is not both a get and let
statement for a property then the process fails to convert that property
to
XML.  

So if MS does it, is that capability publicly available?  Is there a
property iterator buried in the innards of the class object?

John W. Colby
Colby Consulting
www.ColbyConsulting.com 

_______________________________________________

 

_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com

The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI BusinessSensitve material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.





More information about the dba-VB mailing list