|
[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. |
|
|
|
|
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
|
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625