devxlogo

July 21, 2003

IsMemberSupported – Check whether an object supports a member with the specified name

‘ Check whether an object supports a member with the specified name” Examples:’ Debug.WriteLine(IsMemberSupported(Button1, “BackColor”)) ‘ => True’ Debug.WriteLine(IsMemberSupported(Button1, “Focus”)) ‘ => True’ Debug.WriteLine(IsMemberSupported(Button1, “TextColor”)) ‘ => False’ Debug.WriteLine(IsMemberSupported(Button1, “Print”))

InvokeMethod – Invoking a method via reflection

‘ Invoke a method via reflection and return its result – return null if method ‘ doesn’t exist or throws’ Note: requires Imports System.Reflection” Example:’ Function GetCompleteName(ByVal firstName As String,’

GetProperty – Reading a property via reflection

‘ Read a property via reflection or return a default value’ Example: MessageBox.Show(GetProperty(Button1, “Text”, “”))Function GetProperty(ByVal obj As Object, ByVal propertyName As String, _ ByVal defaultValue As Object) As Object

SetProperty – Setting a property via reflection

‘ Set a property via reflection and return True if successful’ Example: SetProperty(Button1, “Text”, “Click me”)Function SetProperty(ByVal obj As Object, ByVal propertyName As String, _ ByVal val As Object) As