|
-
Oct 20th, 2009, 02:54 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Assignment Problem
Dear All,
I cannot understand the reason for what is happening. I am using VB.Net 2008 Express.
I am trying to move a button on a form, the button status is unlocked. The code that I want to use is:
Code:
Me.btnEnter.Location.Y = 474
However, I get the error message, “Expression is a value and therefore cannot be the target of an assignment”
If I now code as follows, I get the error message, “Property access must assign to the property or use its value”
Code:
Me.btnEnter.Location.Y
The errors appear contradictory. Just to check, I wrote the following code:
Code:
X = Me.btnEnter.Location.Y
And when run I received the correct answer of 535.
What is happening? What am I missing?
Regards,
John
-
Oct 20th, 2009, 03:23 AM
#2
Addicted Member
Re: Assignment Problem
If you've looked closely at the Intellisense combobox, the Location property accepts/returns a System.Drawing.Point structure. To assign a new location to an existing control, you'll have to declare a new Point of the location in x,y co-ordinates and assign it to the Location property of that control.
For e.g.:
Code:
Me.btnEnter.Location = New System.Drawing.Point(40,474)
If you want to keep the X co-ordinate of the current location of the control but change the Y co-ordinate, you'd do it as:
Code:
Me.btnEnter.Location = New System.Drawing.Point(Me.btnEnter.Location.X, 474)
Point worth noting here is Intellisense is provided in the Studio for a specific reason: to achieve what you want by writing correct code. 
Hope it helps
Anyone who has never made a mistake has never tried anything new. - Einstein
 Peace! 
-
Oct 20th, 2009, 03:35 AM
#3
Thread Starter
Addicted Member
Re: Assignment Problem
garyjohn_2000,
thank you, that works.
but i have another question, which may sound dumb, but i don't know how to get to "intellisense".
what do i do to see it?
regards,
john
-
Oct 20th, 2009, 03:46 AM
#4
Addicted Member
Re: Assignment Problem
 Originally Posted by johnmtb
I am using VB.Net 2008 Express.
All Express editions come with the same Studio as Visual Studio editions. May have less features, but they never compromise on the Intellisense feature.
Intellisense is what looks like this:
Anyone who has never made a mistake has never tried anything new. - Einstein
 Peace! 
-
Oct 20th, 2009, 04:21 AM
#5
Thread Starter
Addicted Member
Re: Assignment Problem
garyjohn_2000,
it appears that i have been using intellisense, but did not understand how to read it correctly.
thank you.
regards,
john
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|