A1VBCode Forums

Need a code to center a form


http://www.a1vbcode.com/vbforums/Topic19021.aspx

By annu_itech - 6/6/2006

having an mdi form...and when i load a child form into it...it gets loaded in any position..

so..need a code to center the child forms when it gets loaded..or show method of that form is called

the resolutions is 1024 by 768.

can any one help me to find it out.

By vshankaa - 7/8/2006

When child form loads put the below code...

Private Sub frmChild_Load()
frmChild.Left = (Screen.Width / 2) - (frmChild.Width / 2)
frmChild.Top = (Screen.Height / 2) - (frmChild.Height / 2)
End Sub