Unhandled Exception

jpdbay

Active member
Joined
Feb 22, 2006
Messages
31
Programming Experience
Beginner
hi!

I'm getting this msg:
An unhandled exception of type 'System.NullReference Exception' occured.
Object reference not set to an instance of an object. Can any1 explain why am I getting this message?

I created an object of DLL reference to access methods in the COM DLL. Code snippet:

Dim oSC as Reader.Access
Dim str1, str2, str3 As String

StartSession()

TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""

' Read Record
str1 = oSC.ReadCard(hReader, &H0, &H20)
str2 = oSC.ReadCard(hReader, &H20, &H40)
str3 = oSC.ReadCard(hReader, &H40, &H60)

TextBox1.Text = Trim(str1)
TextBox2.Text = Trim(str2)
TextBox3.Text = Trim(str3)

Please help:confused:
 
Hi vis781,

The exception is thrown after these lines of code:

str1 = oSC.ReadCard(hReader, &H0, &H20)
str2 = oSC.ReadCard(hReader, &H20, &H40)
str3 = oSC.ReadCard(hReader, &H40, &H60)

Thnx,
jpdbay
 
This probably reads nothing: oSC.ReadCard(hReader, &H0, &H20)
Try this:

VB.NET:
str1 = "" & oSC.ReadCard(hReader, &H0, &H20)

or check for null:

VB.NET:
if not isdbnull(oSC.ReadCard(hReader, &H0, &H20)) then
str=oSC.ReadCard(hReader, &H0, &H20)
end if
 
Back
Top