Solved

How to get the Properties of any Object at Runtime?

Posted on 1998-12-22
9
188 Views
Last Modified: 2010-05-03
I would like to know how to get a list of exposed public properties of a given object at runtime and probably have a list of them in any form, as a collection or as an array...any thing.
0
Comment
Question by:teluguvadu
9 Comments
 

Author Comment

by:teluguvadu
ID: 1452063
This is urgent
0
 
LVL 1

Expert Comment

by:khaledc
ID: 1452064
Well you can not have an array of all the properties of an object. All what you can do is save the properties of a certain object one by one to User Defined Type variable or declare a variable as the object.
eg:
Dim MyObject as Form 'MyObject will be a Form Type variable
then you can assign this variable to your form
MyObject=form1   'THis will save all the needed property of form1 in MyObject
I hope that answer your quesiton
0
 
LVL 2

Expert Comment

by:PedroG
ID: 1452065
that way you will not know the properties of an unknown automatation object, and in order to do that you must go deep into COM
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Expert Comment

by:stingray
ID: 1452066
Have what you need.  Just found it in the last two days.  Send me your e-mail address and I will send the info to you.  (Have to find out where I saved it in the mean time).

stingray@canada.com
0
 

Author Comment

by:teluguvadu
ID: 1452067
Yes, What Khaledc has proposed does'nt help. I guess PedroG has some suggestions and it looks likes stingray too is thinking in the same lines.
0
 
LVL 3

Expert Comment

by:vmano
ID: 1452068
stingray,
can you please post your code so that all (other) experts can take a look at it???

thanks
vmano
0
 

Author Comment

by:teluguvadu
ID: 1452069
The code stingray suggested does'nt help me. I am sorry if it has dampened the urgency.

Thanks
Teluguvadu
0
 
LVL 2

Expert Comment

by:PedroG
ID: 1452070
Teluguvado, you must serch to find how to query the object for its interface, i know it has something to do with the implementation of the IUknown interface.

I'm sory i can't help you right now cos i'm with no free time, i will check this in a few days if still now answer i will search to try and find one
0
 
LVL 1

Accepted Solution

by:
wdavidsmith earned 120 total points
ID: 1452071
If the properties are "public" they should be accessible...

Sub ListProperties(objWhatever As Object)

   Dim prpTemp As Property
   
   ' Loop through the object's properties collection
   For Each prpTemp In objWhatever.Properties
      Debug.Print "Property Name: " & prpTemp.Name
      Debug.Print "Property Value: " & prpTemp.Value
      Debug.Print ""
   Next prpTemp

End Sub

This is the case with database objects (DAO) and should be true for any object that has a properties collection.

I hope this helps...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question