error message in vb2005

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I am new to vb2005. I have two list boxes on a form. one on the left and
the other on the right. The left contains a list of items. Between the two
list boxes I have a button to add selected items in the left list box to the
right list box.

Programmatically, I need to item I am trying to add from the left list box
is not already in the right list box so as not to create a duplicate entry.
When I click on the add button, it calls a function in a module to verify
that the item in the left list box is not already in the right list box. But
I got the following message, and I have not a clue what I need to resolve
this:

"Reference to a non-shared member requires an object reference."

Can you share some thoughts with me on this? Thanks in advance.


Ben

--
 
Ben said:
Hi all,

I am new to vb2005. I have two list boxes on a form. one on the left and
the other on the right. The left contains a list of items. Between the
two
list boxes I have a button to add selected items in the left list box to
the
right list box.

Programmatically, I need to item I am trying to add from the left list box
is not already in the right list box so as not to create a duplicate
entry.
When I click on the add button, it calls a function in a module to verify
that the item in the left list box is not already in the right list box.
But
I got the following message, and I have not a clue what I need to resolve
this:

"Reference to a non-shared member requires an object reference."

Can you share some thoughts with me on this? Thanks in advance.

Google is your friend.

http://www.google.com/search?hl=en&...quires+an+object+reference&btnG=Google+Search
 
Ben,

The reason for this can be many however finds its base in object oriented
programming.

If we forget shared which has nothing to do with objects than you make
yourself an object using the keyword "new".

This can be global to your program (not project) by typing it outside a
methode or dedicated to a method, which will be out of scope (destructed) at
the end of the method.

In short.

private a as WhateverClass, creates a place to put your object in (only the
address, which is called the reference).
a = new WhateverClass, creates the object.

This can done as well in one time
private a as new WhateverClass

As long that the reference is filled you can use it in your program.

However for nice memory use you can as well put it in the method (I prefer
that not only because of memory use)

Dim and than the same as with the private.

However do you never construct with the "new" an object in that place you
will get the error you got.

Cor
 
Back
Top