Home All Groups Group Topic Archive Search About

Form Properties Changes On It's Own!

Author
9 Oct 2005 9:21 PM
Arpan
Sometimes I find that though I have specified the height & width of a
Form (in the Properties Window), after running it, the value/s changes
on its own. For e.g. I set the height of a Form to 4135 but after
running it once, I find VB changing it to 4140! Though a difference of
5 (pixels, is it...or points?) hardly makes any difference, why does
this happen & how do I make VB adhere to the property values that I
have set?

Thanks,

Arpan

Author
9 Oct 2005 10:53 PM
Jeff Johnson [MVP: VB]
"Arpan" <arpan***@hotmail.com> wrote in message
news:1128892886.423127.8380@g49g2000cwa.googlegroups.com...

> Sometimes I find that though I have specified the height & width of a
> Form (in the Properties Window), after running it, the value/s changes
> on its own. For e.g. I set the height of a Form to 4135 but after
> running it once, I find VB changing it to 4140! Though a difference of
> 5 (pixels, is it...or points?) hardly makes any difference, why does
> this happen & how do I make VB adhere to the property values that I
> have set?

At normal font sizes there are 15 twips per pixel. Since you can't specify
anything smaller than a pixel, VB will round twip settings to the nearest
multiple of 15.
Author
10 Oct 2005 3:28 AM
Someone
Forms position and size are always in Twips, which is usually 15 twips per
pixel, it's not fixed, but it depend on the screen's resolution. Use
Screen.TwipsPerPixelX and Screen.TwipsPerPixelY to find out their values.
Don't hard code them as constants.

In your case, 4135/15 = 275.666666 Pixels, so VB rounded it up 276 pixels,
which equals 4140 twips. Try this code which prints the screen resolution in
Twips and Pixels:

Private Sub Form_Load()
    Debug.Print Screen.Width, Screen.Height
    Debug.Print Screen.Width / Screen.TwipsPerPixelX, Screen.Height /
Screen.TwipsPerPixelY
End Sub

Also, if you want more fine control of where you place your controls, change
the grid settings in the VB6's Options.


Show quoteHide quote
"Arpan" <arpan***@hotmail.com> wrote in message
news:1128892886.423127.8380@g49g2000cwa.googlegroups.com...
> Sometimes I find that though I have specified the height & width of a
> Form (in the Properties Window), after running it, the value/s changes
> on its own. For e.g. I set the height of a Form to 4135 but after
> running it once, I find VB changing it to 4140! Though a difference of
> 5 (pixels, is it...or points?) hardly makes any difference, why does
> this happen & how do I make VB adhere to the property values that I
> have set?
>
> Thanks,
>
> Arpan
>