Visual Basic Programming Code Examples
Visual Basic > Forms Code Examples
Center a form on the screen
Center a form on the screen
Declare this Subroutine in General Declarations:
Public Sub SubFrmCntr(CurrentForm as Form)
CurrentForm.Move (Screen.Width - CurrentForm.Width) \ 2, (Screen.Height - CurrentForm.Height) \ 2
Load CurrentForm
CurrentForm.show
End Sub
'Then, When you want to center a form:
SubFrmCntr(ME) ' Since me is the object name of the current form
Return