Solved

Object reference not set to an instance of an object.

Posted on 2007-04-01
2
240 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

636 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