Thursday, August 21, 2008

How to Center a Form

Try this code. Hope it can help.

In your module copy then paste this code:

Public Sub CenterForm(f As Form, w)
f.Left = (w.ScaleWidth - f.Width) / 2
f.Top = (w.ScaleHeight - f.Height) / 2
End Sub

In your Form Load:

Private Sub Form_Load()
CenterForm Me, Main
End Sub

This code will centering your form in mdiparent

No comments: