467,161 Members | 877 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

VB 2005 Problems returning a structure from a function

Hi all

I would like some help with this issue. I am new to VB 2005 (OK with VB6)

My problem is that I cannot seem to return a structure from a function.

I defined a structure in a class (from which I instantiated an object).
One of the object methods is supposed to return a data record (a structure).

So, from the routine trying to acquire the record (a routine in a form class) I tried defining a local structure in order to receive the data from the object. But I got the following error:

Value of type 'CMA.class_ClassOne.structureOne' cannot be converted to 'CMA.frmFormOne.structureTwo'.
(even though they both have identical elements!)

Next, I tried defining a local variable of type object to recieve the data record. This seems to work in that I can seemingly retrieve the record, but now I cannot fill a datagridview with the data (which was the whole point). It seems as though it doesn't actually retrieve the data somehow. That is, I can assign the elements which (apparently) belong to the local object variable to particular rows and columns of the datagridview, but nothing happens: the grid remains blank.

More pictorially:

some class
... some protected friend structure
(I had to make it friend, because I got an error that the function couldn't expose the structure if it was private)

... some function returns variable of type structure
(that is the above defined structure)

end some class

some other class (a form)
... define local structure to have the same elements as structure in some class (in order to retrieve data from some class)--- Get can't convert error

Tried this next:
... define local variable of type object: No error, but doesn't seem to work

end some other class

Any help to understand (and fix) what is going on here would be greatly appreciated. My project development has kind of stalled now.


Nov 28 '06 #1
  • viewed: 1053

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by sathyashrayan | last post: by
6 posts views Thread by Generic Usenet Account | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.