17-10-12, 12:42 AM
كاتب الموضوع : AhmedEssawy
يتم ذلك عبر الكائن Screen والذي نقوم بحساب طوله وعرضه وقسمتهم على 2 مع الأخذ في الاعتبار طول وعرض الفورم الخاص بنا .كود :
'within a form
Private Sub Form_Load()
me.move (Screen.Width - me.Width) / 2, _
(Screen.Height - me.Height) / 2
End Sub
'OR: As a reusable function (oForm = form to center):
Public Sub CenterForm(oForm as Object)
on error resume next
oForm.move (Screen.width - oForm.width) / 2, _
(Screen.Height - oForm.Height) / 2
End Sub