I have a form who's height I would like to change in code. I would have
supposed something like the following would work but it does not:
Me.Size.Height = 292
I get "Expression is a value and therefore can not be the target of an
asignment"
What am I missing? 19 10725
Size is a class, not a simple structure. Try one of the following:
Me.Height = 292
or
Me.Size = new Size(Me.Size.Width, 292)
-----
Rafael Pivato
"Woody Splawn" <wo***@splawns.com> escreveu na mensagem
news:e0*************@TK2MSFTNGP10.phx.gbl... I have a form who's height I would like to change in code. I would have supposed something like the following would work but it does not:
Me.Size.Height = 292
I get "Expression is a value and therefore can not be the target of an asignment"
What am I missing?
"Woody Splawn" <wo***@splawns.com> scripsit: I have a form who's height I would like to change in code. I would have supposed something like the following would work but it does not:
Me.Size.Height = 292
I get "Expression is a value and therefore can not be the target of an asignment"
Use 'Me.Height = 292' instead.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Hi Woody,
The documentation for Size says that you can get or set the Width and
Height, which is entirely reasonable. What it doesn't say is that you <can't>
when it's the Size of a Control!! The bit you're missing is informative
documentation!!
You can create a new Size and assign it in one go.
Me.Size = New Size (Me.Size.Width, 292)
But it's easier to say Huh! to the Size and just go for the Height
Me.Height = 292. ;-))
Regards,
Fergus.
Hi Rafael,
Size <is> a structure, but its fields are read-only in Controls, for some
reason.
Regards,
Fergus
Fergus,
Fundamentally it is a class for sure. The question that, maybe, you are
trying to rise is that this class inherits System.ValueType, but that is a
long question.. They are not Pascal-like (VB6-like) structures.
And more. Size.Width and Size.Height are not read-only properties from Size.
The problem was that Woody was trying to access indirectly the Form.Size. It
can't.
Look at this code. It will work too:
Dim MySize as Size
MySize = Me.Size ' value assignment
MySize.Width = 294
Me.Size = MySize ' value assignment again
The indirect assignment uses a "temporary allocation" that will raise the
error:
Me.Size.Width = 294
Look at this topic from MSDN: "Expression is a value and therefore cannot be
the target of an assignment" from Visual Basic Reference Error Messages.
-------------------------------
Rafael Pivato
"Fergus Cooney" <fi******@tesco.net> escreveu na mensagem
news:e5**************@tk2msftngp13.phx.gbl... Hi Rafael,
Size <is> a structure, but its fields are read-only in Controls, for
some reason.
Regards, Fergus
"Fergus Cooney" <fi******@tesco.net> schrieb Size <is> a structure, but its fields are read-only in Controls, for some reason.
Really? I think, the thing is that retrieving the Size returns a copy of the
Size (because it is a value type), and changing the property of the copy
doesn't make sense.
--
Armin
:-) nice and clean.... :-)
"Armin Zingler" <az*******@freenet.de> escreveu na mensagem
news:%2****************@TK2MSFTNGP12.phx.gbl... "Fergus Cooney" <fi******@tesco.net> schrieb Size <is> a structure, but its fields are read-only in Controls, for some reason. Really? I think, the thing is that retrieving the Size returns a copy of
the Size (because it is a value type), and changing the property of the copy doesn't make sense.
-- Armin
Hi Rafael,
|| Fundamentally it [Size] is a class for sure.
For me a ValueType is not a class in the sense that it
is an embedded structure and a containing object has
(needs) no object reference to access it. No object.
No independant existance. To me it is not a class but
it is class-like in that it inherits from System.Object
and System.ValueType.
I imagine your definition of 'fundamentally' discounts the
above definition.
For me the lack of independent existence and object
reference are fundamental.
|| Size.Width and Size.Height are not read-only properties of Size.
True. Lol, it would be strange if they were.
I said that <in Controls> they are read-only.
|| Look at this topic from MSDN: "Expression is a
|| value and therefore cannot be the target of an
|| assignment" from Visual Basic Reference Error Messages.
The topic says
|| An expression occurs in a context that assigns a value to it.
|| Only writeable variables, properties, and array elements
|| can have values assigned to them during execution.
I'm not sure why you want me to read it. It says exactly what
I said but in more words - Size.Width and Size.Height are
read-only in [the context of] Controls.
|| The problem was that Woody was trying to access indirectly
|| the Form.Size. It can't.
I was aware of both those facts. Here's my challenge - and the
only bit of this that matters -
Can you say why? ;-)
Regards,
Fergus
Hi Armin,
Doh! ;-)
Regards,
Fergus
Hi Rafael,
Challenge rescinded. I hadn't seen Armin's post at that point. Sorry - no
points to be scored - they've already been allocated. :-)
Regards,
Fergus.
Fergus,
First, review the OOP paradigm.
Other comments follow...
"Fergus Cooney" <fi******@tesco.net> escreveu na mensagem
news:OW**************@tk2msftngp13.phx.gbl... Hi Rafael,
|| Fundamentally it [Size] is a class for sure.
For me a ValueType is not a class in the sense that it
See the framework reference...
is an embedded structure and a containing object has (needs) no object reference to access it. No object. No independant existance. To me it is not a class but it is class-like in that it inherits from System.Object and System.ValueType.
I imagine your definition of 'fundamentally' discounts the above definition.
For me the lack of independent existence and object reference are fundamental.
You are confused. To help you I just can say: the "structure" is an
abstraction.
The fact that you can't reference an object doesn't mean that it's not a
class instance (object again).
If you still concerned about it I suggest you to open another thread. || Size.Width and Size.Height are not read-only properties of Size.
True. Lol, it would be strange if they were. I said that <in Controls> they are read-only.
hmmmm....
|| Look at this topic from MSDN: "Expression is a || value and therefore cannot be the target of an || assignment" from Visual Basic Reference Error Messages.
The topic says || An expression occurs in a context that assigns a value to it. || Only writeable variables, properties, and array elements || can have values assigned to them during execution.
Take a look again... indirect use, temporary allocation and, as you said,
value types... it's trivial... I'm not sure why you want me to read it. It says exactly what I said but in more words - Size.Width and Size.Height are read-only in [the context of] Controls.
There is no read-only trouble. It's related to indirect access of value
type.
|| The problem was that Woody was trying to access indirectly || the Form.Size. It can't.
I was aware of both those facts. Here's my challenge - and the only bit of this that matters -
Can you say why? ;-)
That's your challenge? Please....
Again. Temporary allocation; Value types and Indirect access.
Regards, Fergus
---------
Rafael Pivato
:-) Gotcha! ;-)
Hey! I am working here!!! :-)
"Fergus Cooney" <fi******@tesco.net> escreveu na mensagem
news:%2****************@TK2MSFTNGP09.phx.gbl... Hi Rafael,
Challenge rescinded. I hadn't seen Armin's post at that point. Sorry -
no points to be scored - they've already been allocated. :-)
Regards, Fergus.
-------
Rafael Pivato
Hi Rafael,
|| :-) Gotcha! ;-)
You have? How so?
|| Hey! I am working here!!! :-)
What do you mean?
Regards,
Fergus
Hi Rafael,
|| First, review the OOP paradigm.
How long is it going to take you to review the OOP paradigm?
|| Other comments follow...
Follow what?
Regards,
Fergus
don't feel angry... some day you will learn...
"Fergus Cooney" <fi******@tesco.net> escreveu na mensagem
news:uB***************@tk2msftngp13.phx.gbl... Hi Rafael,
|| :-) Gotcha! ;-)
You have? How so?
|| Hey! I am working here!!! :-)
What do you mean?
Regards, Fergus
Sorry Fergus, I didn't want to make you feel so angry.
"Fergus Cooney" <fi******@tesco.net> escreveu na mensagem
news:u3**************@TK2MSFTNGP09.phx.gbl... Hi Rafael,
|| First, review the OOP paradigm.
How long is it going to take you to review the OOP paradigm?
|| Other comments follow...
Follow what?
Regards, Fergus
I'm not angry.
You don't say anything.
So ..
I'm just bored.
:-(
I'm not so angry.
You don't say anything.
That makes sense to me.
:-(
Hi Rafael,
Lol. You'd know if I was angry - Brother, would you know!!
I'm mostly stirred up by unfairness and inconsiderate behaviour towards
others ('colleagues' or 'guests'). Only a very select few (three I think) have
discovered what it feels like to be in my sights when I'm really serious about
such an issue, though many, I guess, have watched.
I'm just getting tired - long day - I'm adding back the Hi and Regards so
you know that I'm not angry with you. ;-)
Regards,
Fergus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ALESSANDRO Baraldi |
last post by:
Hi and Good Sunday.
Have i any way to Reduce at Runtime, with
no change on Design View, the Height property
of Detail_Section on my Report.....?
The Section Property is Read_Only but if
i...
|
by: Daylor |
last post by:
is there way to change the height of the caption ?
|
by: liups |
last post by:
Hi,
I just come across this, how can I make a form's height larger than
780 pixels?
Thank you.
|
by: Tor Inge Rislaa |
last post by:
How to change row height in a DataGrid
I have DataGrid that is filled with data from a table in a DataSet. The
content of the cells is text of more than one line (as a note field). What I...
|
by: Rune Jacobsen |
last post by:
Hi all,
I have an application with one particular form that lists a number of
items in a listview. In addition to the listview, there is a panel on
top with some simple controls to go back and...
|
by: ck.kislay |
last post by:
Visual stdio 2.0 doesnot support the change in height of the Trackbar
control.Is there any way to change the height of the TrackBar Control.
Waiting for reply.
Chandan
|
by: Revathi Priya |
last post by:
how can i change the height and width of an iframe dyanamically...
i mean how to access the height and width
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |