473,395 Members | 1,846 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,395 software developers and data experts.

Change form height syntax

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?

Nov 20 '05 #1
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?

Nov 20 '05 #2
"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>
Nov 20 '05 #3
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.
Nov 20 '05 #4
Hi Rafael,

Size <is> a structure, but its fields are read-only in Controls, for some
reason.

Regards,
Fergus
Nov 20 '05 #5
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

Nov 20 '05 #6
"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

Nov 20 '05 #7
:-) 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

Nov 20 '05 #8
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
Nov 20 '05 #9
Hi Armin,

Doh! ;-)

Regards,
Fergus
Nov 20 '05 #10
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.
Nov 20 '05 #11
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
Nov 20 '05 #12
:-) 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
Nov 20 '05 #13
Hi Rafael,

|| :-) Gotcha! ;-)

You have? How so?

|| Hey! I am working here!!! :-)

What do you mean?

Regards,
Fergus
Nov 20 '05 #14
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
Nov 20 '05 #15
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

Nov 20 '05 #16
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

Nov 20 '05 #17
I'm not angry.

You don't say anything.

So ..

I'm just bored.

:-(
Nov 20 '05 #18
I'm not so angry.

You don't say anything.

That makes sense to me.

:-(
Nov 20 '05 #19
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
Nov 20 '05 #20

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

Similar topics

4
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...
2
by: Daylor | last post by:
is there way to change the height of the caption ?
22
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.
2
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...
1
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...
1
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
1
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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...
0
tracyyun
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...

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.