|
I can understand your bemusement to this issue. It took me a few weeks to work this out before finally getting to grips with all the changes.
To be honest though you are very close to a solution....
As you discovered, the form object contains a collection called 'CONTROLS,' and within this the property are the controls themselves. I would advise keeping the information in there and using it. The following code will do what I think you are after achieving:
Dim x As Control
For Each x In Me.Controls
Select Case (x.GetType.ToString)
Case "System.Windows.Forms.TextBox"
Dim y As TextBox = CType(x, TextBox)
MsgBox(y.Text)
Case Else
' Do nothing
End Select
Next
Note that I used the CTYPE function to change the generic object
x,' which is of type CONTROL to the type that is desired (in this case a textbox). You should note that the case uses the fully qualified name of the type. So if you were to add comboboxes to this, then you would perhaps add the case "System.Windows.Forms.ComboBox." Hope that helps.
|