Philippe Renaud
asked on
For each in Me.Controls Part 2
Chaosian, shall I, in my form_Load() do this:
For Each ctrl As Control In Me.Controls
If TypeOf (ctrl) Is Button Then
myButtons.Add(ctrl.Name, Nothing)
ElseIf TypeOf (ctrl) Is Label Then
myLabels.Add(ctrl.Name, Nothing)
End If
Next
Something like that, to put all my controls in my Dictionnary tables
Not sure what to put in the value parameter also
For Each ctrl As Control In Me.Controls
If TypeOf (ctrl) Is Button Then
myButtons.Add(ctrl.Name, Nothing)
ElseIf TypeOf (ctrl) Is Label Then
myLabels.Add(ctrl.Name, Nothing)
End If
Next
Something like that, to put all my controls in my Dictionnary tables
Not sure what to put in the value parameter also
ASKER
It was a Dictionnary
ASKER
Im noob with HashTable and Dicotnnary actually.
I just gave points in part 1 for the Dictonnary example, i found it great but, I dont know in fact wich one is the Best for wich situation. anyway.
I just gave points in part 1 for the Dictonnary example, i found it great but, I dont know in fact wich one is the Best for wich situation. anyway.
could you give a link to the first question :o)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes
I did :
Dim myButtons As Dictionary(Of String, Button)
Dim myLabels As Dictionary(Of String, Label)
Also, i am getting an error here:
myLabels.Add(ctrl.Name, ctrl)
not sure why, let me try again
I did :
Dim myButtons As Dictionary(Of String, Button)
Dim myLabels As Dictionary(Of String, Label)
Also, i am getting an error here:
myLabels.Add(ctrl.Name, ctrl)
not sure why, let me try again
What is the error?
ASKER
ok it focus on the lign : myLabels.Add(ctrl.Name, ctrl)
saying:
System.NullReferenceExcept ion was unhandled
Object reference not set to an instance of an object.
saying:
System.NullReferenceExcept
Object reference not set to an instance of an object.
ASKER
dont understand why
the value parameter is what is displayed to the user. Are myButtons and myLabels Hashtable?
Apresto