Error durring compile code

C

cmdolcet69

When i compile the code below it error out saying that Object
Reference not set to an instance of an object......


Public newRuntimeClass As NewRuntimeMethods

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click

If Len(Me.txtBarCode.Text) = 12 Then
newRuntimeClass.ScannedBarCode = Me.txtBarCode.Text
Close()
Else
MessageBox.Show("The Current BarCode Scanned was not
correct, Please Re Enter")
Me.txtBarCode.Text = String.Empty
txtBarCode.Focus()
End If
End Sub
 
T

Teemu

cmdolcet69 said:
When i compile the code below it error out saying that Object
Reference not set to an instance of an object......


Public newRuntimeClass As NewRuntimeMethods

It should be:

Public newRuntimeClass As New NewRuntimeMethods

-Teemu
 
C

cmdolcet69

It should be:

Public newRuntimeClass As New NewRuntimeMethods

-Teemu

When i place the New keyword in front of the class it will ask me for
all these parameters.
 
F

Family Tree Mike

Then it appears your constructor for the NewRuntimeMethods requires
parameters to be passed to it. You must then do something like

Public newRuntimeClass as New NewRuntimeMethods(a, b, c)

Also, I believe you meant to say you get the "object not set to instance"
error at runtime. It shouldn't happen at compile time.
 
K

kimiraikkonen

It should be:

Public newRuntimeClass As New NewRuntimeMethods

-Teemu

I also checked it on vb.net 2005 "express" but there's nothing called
"newRuntimeMethods".

Only "RuntimeMethodHandle" exists with most similarity. Is it a
special class or not express version?
 
H

Herfried K. Wagner [MVP]

kimiraikkonen said:
I also checked it on vb.net 2005 "express" but there's nothing called
"newRuntimeMethods".

It seems to have to do something with scanning barcodes as it has a
'ScannedBarCode' property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top