The following program will deduct the height (or width) occupied by the task bar when calculating. If there is a shortcut bar that starts Microsoft Office, the height (or width) occupied by the shortcut bar will also be deducted.
PublicConstSM_CXFULLSCREEN=16
PublicConstSM_CYFULLSCREEN=17
#IfWin32Then
DeclareFunctionGetSystemMetricsLib"user32"(ByValnIndexAsLong)AsLong
#Else
DeclareFunctionGetSystemMetricsLib"User"(ByValnIndexAsInteger)AsInteger
#EndIf
PublicSubCenterForm(frmAsForm)
frm.Left=Screen.TwipsPerPixelX*GetSystemMetrics(SM_CXFULLSCREEN)/2-frm.Width/2
frm.Top=Screen.TwipsPerPixelY*GetSystemMetrics(SM_CYFULLSCREEN)/2-frm.Height/2
EndSub
Just use CenterFormMe in Form_Load ->