Solved

Returning an object.

Posted on 1999-01-25
3
184 Views
Last Modified: 2013-11-26
Hi. Problem. I have a program which has a method which returns an object. The problem is that when the object is returned, it only has the correct value for the object name, which is the default property. However, when the object is set in the procedure, debugging shows that all the properties are set. It's as if the object is being passed 'byref' as oppose to 'byval'.

If anyone can help, I'd appreciate it.
0
Comment
Question by:NikW
3 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 1470489
Your method may be returning a New instance of the object or something like that.

I can make a few educated guesses but the best thing is for your to paste your code so experts can analyse it.
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 20 total points
ID: 1470490
You most likely do something like this in your subroutine

--- BEGIN CODE ---
function myfunction ()
   dim yyy as MyObject
   .....
   .....
   myfunction = yyy
end function

Dim xxx as myobject
xxx = myfunction
--- END CODE ---

This copies only the default value.
Use
set xxx = myfunction
and
set myfunction = yyy
0
 

Author Comment

by:NikW
ID: 1470491
Of course! How stupid of me!

0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question