Solved

Returning an object.

Posted on 1999-01-25
3
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

717 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