Object Properties

  • Thread starter Thread starter abillmeier
  • Start date Start date
A

abillmeier

I have created a custom object with several properties that use private
variables. I used an object with properties so I could better control
validation and share the code between applications.

Is it possible to access object properties as if they were in a collection?
I would like to be able to retrieve and update the properties kinda like:
objectinstancename("propertyname")


Can this be done? Do I need to handle this in a differnet manner or add
additional code to allow it?

Thanks in advance.
 
abillmeier said:
Is it possible to access object properties as if they were in a collection?
I would like to be able to retrieve and update the properties kinda like:
objectinstancename("propertyname")

Why? Isn't

objectinstancename.propertyname

better than what you propose? You get intellisense and it's fewer
character to type. If you must access using a string, then reflection
will work for that, but it will more typing rather than less and more
prone to errors.
 
abillmeier wrote:
Is it possible to access object properties as if they were in a collection?
I would like to be able to retrieve and update the properties kinda like:
objectinstancename("propertyname")
<snip>

VB.Net still supports the good old "CallByName" function:

SomeValue = CallByName(Obj, "PropName", CallType.Get)

HTH.

Regards,

Branco.
 

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