Thread: VB.Net Error
View Single Post
Old 06-22-2005, 01:03 PM   #1 (permalink)
Mohan Giri
 
True Techie

Join Date: Dec 2004

Posts: 145

Mohan Giri

Default VB.Net Error

Hi,
I tried a simple program in vb.net. In that program I used a class. Ok. I feel difficult to explain. I will post my code here.

Class Definition:

Public Class emp
Public ename As String
Public salary As Integer
Public eno As Integer
End Class


Form Load event code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim x As emp
x.ename = "Rajesh"
x.eno = 1086
x.salary = 10000
MsgBox(CType(x, emp).eno)
End Sub
End Class

I got an error.

An unhandled exception of type 'System.NullReferenceException' occurred in empdetails.exe

Additional information: Object reference not set to an instance of an object.

Anybody can help me to resolve this error??

Thanks in advance
Mohan Giri is offline