PC Review


Reply
Thread Tools Rate Thread

Change form height syntax

 
 
Woody Splawn
Guest
Posts: n/a
 
      8th Oct 2003
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?



 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      8th Oct 2003
"Woody Splawn" <(E-Mail Removed)> 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>
 
Reply With Quote
 
Rafael Pivato
Guest
Posts: n/a
 
      8th Oct 2003
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" <(E-Mail Removed)> escreveu na mensagem
news:(E-Mail Removed)...
> 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?
>
>
>



 
Reply With Quote
 
Fergus Cooney
Guest
Posts: n/a
 
      8th Oct 2003
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.


 
Reply With Quote
 
Fergus Cooney
Guest
Posts: n/a
 
      8th Oct 2003
Hi Rafael,

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

Regards,
Fergus


 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      8th Oct 2003
"Fergus Cooney" <filter-(E-Mail Removed)> 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

 
Reply With Quote
 
Rafael Pivato
Guest
Posts: n/a
 
      8th Oct 2003
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" <filter-(E-Mail Removed)> escreveu na mensagem
news:(E-Mail Removed)...
> Hi Rafael,
>
> Size <is> a structure, but its fields are read-only in Controls, for

some
> reason.
>
> Regards,
> Fergus
>
>



 
Reply With Quote
 
Rafael Pivato
Guest
Posts: n/a
 
      8th Oct 2003
:-) nice and clean.... :-)

"Armin Zingler" <(E-Mail Removed)> escreveu na mensagem
news:%(E-Mail Removed)...
> "Fergus Cooney" <filter-(E-Mail Removed)> 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
>



 
Reply With Quote
 
Fergus Cooney
Guest
Posts: n/a
 
      8th Oct 2003
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


 
Reply With Quote
 
Fergus Cooney
Guest
Posts: n/a
 
      8th Oct 2003
Hi Armin,

Doh! ;-)

Regards,
Fergus


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change form detail section height? Max Moor Microsoft Access Forms 0 18th Jul 2007 01:19 AM
How do I change the header height in an Access form datasheet? =?Utf-8?B?QW5kcmV3TU9sc29u?= Microsoft Access Forms 2 26th Apr 2006 08:26 PM
Change width/height of a form mike Microsoft Access Form Coding 2 12th Nov 2003 08:55 AM
change form height at runtime moondaddy Microsoft Access Form Coding 2 6th Nov 2003 11:51 PM
taskbar height doubled - can't change back to normal height Lyn Windows XP General 2 20th Oct 2003 11:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:36 PM.