0

I'm trying to pass a business object from one WinForm to another WinForm for modification, and then repopulate the text boxes, etc. on the first form with the updated values.

However, it seems that the object values set in the second form are not "sticking" when the code control returns to the first form.

Is there a way to view the memory location of an object in VB.NET? I want to first make sure that the object variable on the second form is pointing to the same memory address as the object on the first form. Then I can take it from there.

In a separate VB project, I passed a simple object to a second form, modified the values, and re-displayed the object's values on the first form. It worked fine. In my real app, I'm passing an object that is a property of another object, which may be why it isn't working.

SOLUTION: The problem was that I was using a DeepCopy() function that I found to simplify copying the properties of one object to another. Removing that function and manually setting the values to the passed object on the second form (ex. obj.property1 = searchResult.property1) makes everything behave as expected.

1 Answer 1

3

You cannot see the memory address of an object in VB.NET.

Could you show us a bit of code? Maybe we can spot the error.

What kind of object are you passing around? If the object is a value type, this will not work (declared with Structure instead of Class).

Sign up to request clarification or add additional context in comments.

1 Comment

I was just about to say that. In .NET bjects normally behave as you describe that you want, HardCode. Some code will help put the finger on what's happening.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.