Solved

Object reference not set to an instance of an object.

Posted on 2007-04-01
2
195 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
Comment Utility
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
Comment Utility
ANgel,

HAHAHA!!!

Silly me!!!

Beginners mistake!!!

Jack
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Trouble with References... 5 21
VB.NET HttpWebRequest 12 29
Calling stored proc in EDMX 11 17
Different Delete Messages 7 4
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now