Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dictionnary.add()

Posted on 2006-07-17
2
Medium Priority
?
182 Views
Last Modified: 2010-04-23
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 !?!!?
0
Comment
Question by:PhilippeRenaud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
bchoor earned 2000 total points
ID: 17125017
2 alternatives

1.
Private Sub....

if myButtons is Nothing then myButtons = New Dictionary(Of String, Button)
if myLabels is nothing then myLabels = New Dictionary(Of String, Label)

For each...


End Sub

or
2.
Dim myButtons As New Dictionary(Of String, Button)
Dim myLabels As new Dictionary(Of String, Label)

HTH
~BC
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 17125040
duh, you're right. needed the  "new' ....
 thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question