Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9249539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:13:17+00:00 2026-06-18T10:13:17+00:00

Goal: filling some TextBoxes Problem: when the first TextBox is filled, the values of

  • 0

Goal: filling some TextBoxes

Problem: when the first TextBox is filled, the values of the next ones are compromised. It happens in three steps.

First step. Say I have to fill two TextBoxes. A public function does this:

Public Sub FillingTextBoxes(Name As String) 
    'Fetching my object from a collection
    Dim newObject As MyClass = MyCollection.Item(Name)

    'Filling two textboxes
    With newObject 
        TextBox1.Text = .Property1.ToString
        TextBox2.Text = .Property2.ToString

MyCollection is a public Microsoft.VisualBasic.Collection.

Second step. Filling TextBox1 triggers a TextChanged event. Another public function changes the values of the same object:

Public Sub SomeOtherFunction(Name As String) 
    Dim newObject As MyClass = MyCollection.Item(Name)
    newObject.Property2 = "something else"

Third step, here it comes. When SomeOtherFunction is done running, back in FillingTextBoxes, the value of newObject.Property2 is now "something else", even though this happened in another function.

How could I possibly solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:13:19+00:00Added an answer on June 18, 2026 at 10:13 am

    If what you are storing in the collection is a custom class then you need to implement a clone function that allows a deep copy.

    Clone funcionality allows you to take an object reference and return a new copy of that same type that is a new reference to a different object. For example if you had this:

    public class MyClass
    
        public Property1 as string
        public Property2 as string
    
        public sub new()
            Property1 = string.empty
            Property2 = string.empty
        end sub
    
        public function clone() as MyClass
            dim returnThis as new MyClass
    
            returnThis.Property1 = Property1
            returnThis.Property2 = Property2        
    
            return returnThis
        end function
    
    end class
    

    Then you could call for a new deep copy like this:

    Public Sub SomeOtherFunction(Name As String) 
        Dim newObject As MyClass = MyCollection.Item(Name).clone()
        newObject.Property2 = "something else"
    

    And you would have no problems because you are using a new copy of the same object instead of the reference in the collection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am filling up a Stackpanel with Textboxes. Each textbox, Should display the Value
Goal: Gain datatype date with year and month Problem: Need to help to convert
Goal: to create a percentage column based off the values of calculated columns. Here's
I have a problem with a webform. My Goal: Intially when a page is
Hello I got goal to achieve, 3d cube manipulated with mouse with gradient filling
Goal: Display the created and customized control library component in the mainform screen Problem:
Goal: Right clicking in the listview and choose different option. Problem: There are two
My goal is populating a section of a tableview by filling data from all
Goal: A variable should contain amount of rows from a specific sheet. Problem: What
Goal: Don't want the user to make changes in the program's size. Problem: Don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.