Link to home
Start Free TrialLog in
Avatar of Philippe Renaud
Philippe RenaudFlag for Canada

asked on

Dictionnary.add()

having error NullReferenceExecption on lign: myLabels.Add(ctrl.name, ctrl)

Imports System.Collections.Generic

 Dim myButtons As Dictionary(Of String, Button)
 Dim myLabels As Dictionary(Of String, Label)
Private Sub frmRoom_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        For Each ctrl As Control In Me.Controls
            If TypeOf (ctrl) Is Button Then
                myButtons.Add(ctrl.name, ctrl)
            ElseIf TypeOf (ctrl) Is Label Then
                myLabels.Add(ctrl.name, ctrl)
            End If
        Next
End Sub


any ideas folks !?!!?
ASKER CERTIFIED SOLUTION
Avatar of bchoor
bchoor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Philippe Renaud

ASKER

duh, you're right. needed the  "new' ....
 thanks.