By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,986 Members | 1,522 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,986 IT Pros & Developers. It's quick & easy.

VB 2005 Problems returning a structure from a function

P: 3
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.

Example:
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.

Sincerely,

--Mike
Nov 28 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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