Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Object reference not set to an instance of an object.

Posted on 2007-04-01
2
Medium Priority
?
244 Views
Last Modified: 2013-11-07
Public Class Form1
    Dim WithEvents Monitor As Timer
    Dim Drives As Dictionary(Of Integer,  System.IO.DriveInfo)

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        For Letters As Int16 = 65 To 90
            Dim mDrives As System.IO.DriveInfo = New System.IO.DriveInfo(Chr(Letters))
            Drives.Add(Letters, mDrives) '--> Getting the error here.
        Next
        Monitor.Start()
    End Sub
end class
0
Comment
Question by:JackOfPH
[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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 18834396
You did not initializae the Drives variable, only declared it.

Public Class Form1
    Dim WithEvents Monitor As Timer
    Dim Drives As Dictionary(Of Integer,  System.IO.DriveInfo)

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Drives = new Dictionary(Of Integer,  System.IO.DriveInfo)

        For Letters As Int16 = 65 To 90
            Dim mDrives As System.IO.DriveInfo = New System.IO.DriveInfo(Chr(Letters))
            Drives.Add(Letters, mDrives) '--> Getting the error here.
        Next
        Monitor.Start()
    End Sub
0
 
LVL 15

Author Comment

by:JackOfPH
ID: 18834431
ANgel,

HAHAHA!!!

Silly me!!!

Beginners mistake!!!

Jack
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

715 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