Centrare Form e Controlli

Routine che centra un qualsiasi form al centro dello Schermo
'*********************************************
''MeForm = nome del Form che deve essere centrato
'*********************************************
Public Sub CentraForm(MeForm As Form)
With MeForm
  .Top = (Screen.Height - .Height) / 2
  .Left = (Screen.Width - .Width) / 2
End With
End Sub

Routine che centra un qualsiasi controllo al centro del Form
'*********************************************
'MyForm = Form contenente il controllo
'MyOggetto = Controllo che deve essere
' centrato nel Form
'*********************************************
Public Sub CentraControllo(MyForm As Form, MyOggetto As Object)
With MyForm
  MyOggetto.Top = (.ScaleHeight / 2) - (MyOggetto.Height / 2)
  MyOggetto.Left = (.ScaleWidth / 2) - (MyOggetto.Width / 2)
End With
End Sub

Testato su: Tutti i Sistemi operativi