Object reference not set to an instance of an object.

  • Thread starter Thread starter Ammneh Azeim via DotNetMonster.com
  • Start date Start date
A

Ammneh Azeim via DotNetMonster.com

I'm getting this error while sending in a refference to a class, in a
method. I'm not sure why I'm getting this error. and how to fix it.
Can someone please let me know. that would be great
here is the code.
fromCheAcc.Transfer(amount, fromAcc, ToAcc)
where fromCheAcc is a type of a cheqying account and fromAcc is type of
account,
Chequing inherits Accounts
and method takes an amount as integer, fromAcc of type Accounts, ToAcc of
type Accounts
 
The error "Object reference not set to an instance of an object" always
means (afaik) that you are referencing an object that is set to nothing. So
now you just need to find what object is set to nothing.

When you run this in debugger does fromCheAcc have a value or is it set to
nothing. Does the error break on this line or in the function .Transfer?

Chris
 
This exeption means you are not instantiating a class into an object before
you use it in code.
Before your program uses the code line that reads:
fromCheAcc.Transfer(amount, fromAcc, ToAcc) do you have lines of code that
use the New keyword to instantiate the objects being used e.g.

the object behind the FromCheAcc variable?
the object behind the fromAcc varialbe?
the object behind the toAcc variable?

--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
 

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

Back
Top