dynamically reposition controls on a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to know the positioning coordinates of a control on a form?
I need a routine that will for example "move all controls on the form 1 inch
to the right".
The code below would work if I had the value for the variable oldPositionX,
but I cannot figure out how to know this dynamically.
Thanks very much.

Dim ctl As Control, cnt As Integer
For Each ctl In Forms(formName).Controls
ctl.Move oldPositionX + 1440
Jay
 
Jay said:
Is there a way to know the positioning coordinates of a control on a form?
I need a routine that will for example "move all controls on the form 1 inch
to the right".
The code below would work if I had the value for the variable oldPositionX,
but I cannot figure out how to know this dynamically.

You're so close! You just need to give the control's Left property for its
current horizontal position, and the control's Top property for its vertical
position (in case you need that in the future). Try it like this:

Dim ctl As Control
Const INCH As Long = 1440

For Each ctl In Forms(formName).Controls
ctl.Move ctl.Left + INCH
Next ctl

Set ctl = Nothing
 
Back
Top