473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How do i assign values to a structure element ??

I'm a newbie with Vb.NET so please excuse me if this is a stupid quetion.

I have declared a structure:

Structure ClientRecord
Public Client_ID As Integer
Public Client_Initials As String
Public Client_Surname As String
End Structure 'ClientRecord

I also have declared a property which is of this type of the structure:

Public Property Client() As ClientRecord
Get
Return FClient
End Get
Set(ByVal Value As ClientRecord)
FClient = Value
End Set
End Property

Now, in another form,i wish to set the values contained in the property
Client:

frmPolicy.Client.Client_ID = CInt(lblClientID.Text)

HOWEVER - I GET THE ERROR:
'Expression is a value and therefore cannot be the target of an assignment".

HOW SHOULD I DO THE ASSIGNMENT?

Any help would be most welcome!

Thanks
Suzie

Feb 4 '06 #1
2 8237
Dont worry guys - I found a better solution by declaring the ClientRecord
datatype as a class instead of a structure. Now i dont have that probelm
anymore.

While i've found a solution i still dont understand what was wrong before
with the code i had, so any comments will still be welcome ...

thanks
Suzie

"Suzie" wrote:
I'm a newbie with Vb.NET so please excuse me if this is a stupid quetion.

I have declared a structure:

Structure ClientRecord
Public Client_ID As Integer
Public Client_Initials As String
Public Client_Surname As String
End Structure 'ClientRecord

I also have declared a property which is of this type of the structure:

Public Property Client() As ClientRecord
Get
Return FClient
End Get
Set(ByVal Value As ClientRecord)
FClient = Value
End Set
End Property

Now, in another form,i wish to set the values contained in the property
Client:

frmPolicy.Client.Client_ID = CInt(lblClientID.Text)

HOWEVER - I GET THE ERROR:
'Expression is a value and therefore cannot be the target of an assignment".

HOW SHOULD I DO THE ASSIGNMENT?

Any help would be most welcome!

Thanks
Suzie

Feb 5 '06 #2
>While i've found a solution i still dont understand what was wrong before
with the code i had, so any comments will still be welcome ...


When it's a structore the property will return a copy of the FClient
value, and when you assign the Client_ID you would just end up
modifying that temporary copy.

When it's a class you get back a reference to the same object and any
changes you ake affects FClient as well.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Feb 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Golf Nut | last post by:
I am finding that altering and affecting values in elements in multidimensional arrays is a huge pain in the ass. I cannot seem to find a consistent way to assign values to arrays. Foreach would...
4
by: steflhermitte | last post by:
Dear cpp-ians, I am working with a structure struct segment { .... vector <meta_segment>::iterator it_Z; .... };
16
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have...
26
by: Brett | last post by:
I have created a structure with five fields. I then create an array of this type of structure and place the structure into an array element. Say index one. I want to assign a value to field3 of...
7
by: Chris Wertman | last post by:
I am so lost on this one. Dim Ary as Integer = New Integer(4) {0,1,2,3} FAILS with the error: Array initializer has 1 too few elements. So I try Dim Ary as Integer = New Integer(3)...
2
by: dBNovice | last post by:
Hi all! I have 3 separate forms: Tasks, Subtasks, and Elements. All 3 is related by TaskId and Subtasks and Elements are related by SubtaskID. In the DB after I add a task, I want to be able to...
11
by: skumar434 | last post by:
Hi everybody, I am faceing problem while assigning the memory dynamically to a array of structures . Suppose I have a structure typedef struct hom_id{ int32_t nod_de; int32_t hom_id;
6
by: Chuck Anderson | last post by:
My knowledge of JavaScript is limited. I learn from example and then adapt those examples to suit my needs. I have stumped myself on this one. I have a form with checkboxes that I want to...
18
by: joaotsetsemoita | last post by:
Hello everyone, I'm having troubles assigning an onclick event to a cell. Im trying something like cursorPoint.cells.style.cursor = "hand"; cursorPoint.cells.width = "20";...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.