Solved

Object reference not set to an instance of an object.

Posted on 2007-04-01
2
217 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
2 Comments
 
LVL 142

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

831 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