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

  • Home
  • SEARCH
  • 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 5986619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:41:51+00:00 2026-05-22T22:41:51+00:00

I have the following Public Structure Foo dim i as integer End Structure Public

  • 0

I have the following

Public Structure Foo
   dim i as integer
End Structure

Public Class Bar

Public Property MyFoo as Foo
Get
   return Foo
End Get
Set(ByVal value as Foo)
   foo  = value
End Set

dim foo as Foo    
End Class

Public Class Other

   Public Sub SomeFunc()    
     dim B as New Bar()    
     B.MyFoo = new Foo()    
     B.MyFoo.i = 14 'Expression is a value and therefore cannot be the target of an assignment ???    
   End Sub
End Class

My question is, why can I not assign to i through my property in the Bar class? What have I done wrong?

  • 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-05-22T22:41:52+00:00Added an answer on May 22, 2026 at 10:41 pm

    The answer is found here, it says the following:

    ' Assume this code runs inside Form1.
    Dim exitButton As New System.Windows.Forms.Button()
    exitButton.Text = "Exit this form"
    exitButton.Location.X = 140
    ' The preceding line is an ERROR because of no storage for Location.
    

    The last statement of the preceding
    example fails because it creates only
    a temporary allocation for the Point
    structure returned by the Location
    property. A structure is a value type,
    and the temporary structure is not
    retained after the statement runs. The
    problem is resolved by declaring and
    using a variable for Location, which
    creates a more permanent allocation
    for the Point structure. The following
    example shows code that can replace
    the last statement of the preceding
    example.

    This is because the struct is only a temporary variable. So the solution is to create a new struct of the type you need, assign it all it’s internal variables and then assign that struct to the struct property of the class.

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

Sidebar

Related Questions

I have the following class public class Car { public Name {get; set;} }
I have the following structure. public class ToolSettings { public string Extension { get;
I have the following class structure: public class Result { protected int Code {get;
I have this following structure: public class Dummy { public string Name { get;
I have the following structure public class MyClass : MyBaseClass<System.Int32> { } In a
I have the following entity structure: public class Party { public Int32 PartyId {
Let's say I have the following class structure: class Car; class FooCar : public
Lets say I have the following: public class MyObject { [Bindable] public var foo:int
I have the following structure: public class A { private javax.swing.JLabel fullName; public class
I have The Following Structure public class GraphData { private List<RecordPerDay> recordPerDay; public List<RecordPerDay>

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.