Here is a sample that shows how to start using reflection. This is a very basic sample, but should start giving you an idea of how to use reflection. Honestly, though it may be hard to believe at first, .NET has a much system of communicating with indirect objects. Once you begin to understand the structure of .NET, the VFP macro will seem clumsy and cumbersome....and practically useless
But believe me, I did not think this at first and I have come a long way since I first wanted to resort back to a weak typed macro.
The first method you need to learn about it GetType(). This method will be instrisically on every object, regardless of the class or control, in .NET. This is the gateway into reflecting an object or class to get to its properties, methods, events, and so on.
Also, as a side note, you will want to use CType() and GetType() instead of TypeOf. It will be much faster. For example, in your code snippet:
If TypeOf ctr Is CheckBox Then
would be faster and more efficient as:
If ctr.GetType() Is GetType(CheckBox) Then
As for the forum questions, press Ctrl+Enter to break for a single line. Enter takes you to a new paragraph. As for tab....sorry, you have to use spaces...at least for now. As for code examples, you can copy from .NET and paste it directly into the editor. It will keep the tabs, but you may have to delete the blank lines and add a Ctrl+Enter to get a single line back in.
Last thing, instead of passing an array over to your pingit method, you should create a generic list with a reference to your controls.
Single Object Type As a CheckBox
'-- Establish Locals
Dim loCheckBoxesOnly As New System.Collections.Generic.List(Of CheckBox)loCheckBoxesOnly.Add(
Me.CheckBox1)
Any Type Of Control
'-- Establish Locals
Dim loAnyControl As New System.Collections.Generic.List(Of System.Windows.Forms.Control)
loAnyControl.Add(Me.CheckBox1)
loAnyControl.Add(Me.Textbox1)
loAnyControl.Add(Me.Textbox2)
I hope this helps. Please let me know if things are still a little fuzzy. My explanation may not be the best.