How can i list properties of a class during runtime?
Thanks
Printable View
How can i list properties of a class during runtime?
Thanks
Adding a reference to library Typelib to your Project you can do it, the only problem is: for some reason it doesn't work when the App is compiled, it only works when running from IDE :ehh: and I don't know if there is a solution for that. Anyway, in the link below you'll find the code:
http://www.vbforums.com/showthread.php?t=476509
Here's another method you can try:
'The code below dumps a list of properties, methods, and events of your
'class from Object Browser, so you can easily write code to save the
'contents. It uses SendKeys and copy from the Clipboard.
'To use it, bring up Object Browser(F2), then select your
'project name from the list, then click on your class.
'You would see the list of properties on the right pane.
'Right click anywhere and make sure that "Group Members"
'is selected. Click on the first property on the right pane,
'then start a new VB IDE instance, add a Timer to Form1,
'then add the code below. Run the project,
'AND SWITCH to the VB IDE that is showing Object Browser.
'After 5 seconds, the running program
'will capture property names and print them to the immediate
'window. From there, you can copy them and do with them
'whatever you want.
Code:Option Explicit
Private Sub Form_Load()
Timer1.Interval = 5000
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
DumpObjectBrowser
End Sub
Private Sub DumpObjectBrowser()
Dim Str As String
Dim LastStr As String
Dim Counter As Long
Clipboard.Clear
Counter = 0
Do
LastStr = Str
SendKeys "^c", True
Delay 0.1
Str = Clipboard.GetText
If LastStr = Str Then
' We reached the end
Exit Do
End If
Debug.Print Str
SendKeys "{DOWN}", True
Delay 0.1
Counter = Counter + 1
Loop Until Counter = 100
Me.Caption = "Done!"
End Sub
Private Sub Delay(ByVal Seconds As Single)
Dim t As Single
t = Timer
Do While Abs(Timer - t) < Seconds
DoEvents
Loop
End Sub
what you need is a typelib viewer...
plenty out there:
http://www.google.com/search?aq=0&oq...typelib+viewer
-tg
but how can i do it during runtime? i want to list all the property of my class and its values during runtime.
you cannot see the property of classes at runtime .because all the these things are hidded in vb6.it is possible in only in c# .but i did notQuote:
but how can i do it during runtime? i want to list all the property of my class and its values during runtime.
understand why do you want to see all the property of any class at runtime ?:)
i want to create a system log. I will store the previous data in a objectA(class) and to new data to objectB(class). then loop to its property to determine what values are different. then save it to a text file.