[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

VB .net Object Reference Error

Asked by dumpsterdivingdave in Microsoft Visual Basic.Net, .NET Framework 3.x versions, .NET

I have the following Code that when run produces an error that states Object Reference Not Set to an Instance of an Object...

On Lines 31 - 34, if I change them so that they have a value in that line (ex change line 31 to read TW.Resolution = 300) then it works just fine.

I checked, and the values are getting read out of the file and are being parsed/interpreted correctly.  So it is not trying to assign blank values...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
Imports Priore.Controls
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Collections
Imports System
Imports System.Xml 
Public Class Form1 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Hide() 
        Dim xDoc As New XmlDocument
        xDoc.Load("config.xml") 
        Dim DPI As XmlNodeList = xDoc.GetElementsByTagName("dpi")
        Dim colourType As XmlNodeList = xDoc.GetElementsByTagName("colourType")
        Dim showIF As XmlNodeList = xDoc.GetElementsByTagName("showInterface")
        Dim showPR As XmlNodeList = xDoc.GetElementsByTagName("showProgress") 
        Dim vDPI As Short = CShort(DPI(0).InnerText)
        Dim vColourType As Twain.TWAIN_CLASS_COLOURTYPE
        Select Case colourType(0).InnerText
            Case "twBW"
                vColourType = Twain.TWAIN_CLASS_COLOURTYPE.twBW
            Case "twGrey"
                vColourType = Twain.TWAIN_CLASS_COLOURTYPE.twGREY
            Case "twRGB"
                vColourType = Twain.TWAIN_CLASS_COLOURTYPE.twRGB
        End Select
        Dim vShowIF As Boolean = CBool(showIF(0).InnerText)
        Dim vShowPR As Boolean = CBool(showPR(0).InnerText) 
        Try 
            Dim TW As Twain
            TW = New Twain(Me.Handle)
            TW.Resolution = vDPI
            TW.ColorType = vColourType
            TW.ShowInterface = vShowIF
            TW.ShowProgress = vShowPR
            TW.StartScan()
            Dim args() As String = Environment.GetCommandLineArgs
            Dim img As New Bitmap(TW.Image)
            TW.Dispose()
            Dim saveLoc As String
            saveLoc = args(1) + "-" + DateTime.Now.Year.ToString + DateTime.Now.Month.ToString + DateTime.Now.Day.ToString + DateTime.Now.Hour.ToString + DateTime.Now.Minute.ToString + DateTime.Now.Second.ToString + ".jpg"
            img.Save(saveLoc, Drawing.Imaging.ImageFormat.Jpeg)
            img.Dispose()
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
        'End
    End Sub
End Class
[+][-]11/04/09 03:03 PM, ID: 25745043Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 04:05 PM, ID: 25745546Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 08:55 AM, ID: 25751462Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 09:12 AM, ID: 25751650Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 09:34 AM, ID: 25751853Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 09:37 AM, ID: 25751872Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 09:38 AM, ID: 25751886Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 10:00 AM, ID: 25752094Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 10:04 AM, ID: 25752129Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 10:36 AM, ID: 25752434Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 10:38 AM, ID: 25752460Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 10:50 AM, ID: 25752588Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 10:52 AM, ID: 25752611Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 11:00 AM, ID: 25752705Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/10/09 06:35 AM, ID: 25785737Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/10/09 09:01 AM, ID: 25787354Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/10/09 01:54 PM, ID: 25790305Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/11/09 09:36 AM, ID: 25797095Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/13/09 07:20 AM, ID: 25814611Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/09 07:48 AM, ID: 25814885Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/09 08:33 AM, ID: 25815282Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/13/09 09:26 AM, ID: 25815789Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/09 09:34 AM, ID: 25815875Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/09 11:16 AM, ID: 25816834Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/09 12:54 PM, ID: 25817611Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/13/09 09:11 PM, ID: 25819476Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625