Public sub
CenterForm(x as
Form, Optional vParent, Optional vShowMode)
dim
oParent as
Object
dim
iMode%
Screen.MousePointer = vbHourglass
If IsMissing(vParent) Then
set
oParent = Screen
Else
set
oParent = vParent
end
If
If IsMissing(vShowMode) Then iMode = vbModeless Else _
iMode = Abs(vShowMode) Mod 2
x.Move (oParent.Width \ 2 - x.Width \ 2), ((oParent.Height \ 2 ) * .85 - x.Height \ 2)
Load x
x.Show iMode
Screen.MousePointer = vbNormal
End Sub
'use as
Call CenterForm(form1)
'this will center
the form1 on
the screen
Call CenterForm(form1,MDIform1)
'this will center
the Childform1 in the MDIform1
Return