Tag Archives: center

Easy way to Center the applications Form during Runtime in VB.Net.

This is a very simple snippet and will work with all versions of Visual Basic.NET.

IF you want to easily and quickly center your Form in relation to the computer screen, just simply call the Subroutine below.

        'This Sub is available in All versions of VB.NET.


That’s all there is to it. Just simply call that Sub whenever you need or want your application/form to center itself while it is running in runtime mode.


How to Center your Form using Visual Basic 6.0

Simple code to center your form with the screen in VB 6.0.

'vb 6.0 and 5.0
Top = Screen.Height / 2 - Height / 2
Left = Screen.Width / 2 - Width / 2

Thanks to Vinz for this updated code. As he mentioned below, VB is indeed faster with multiplication than division.

 Me.Top = Screen.Height * 0.5 - Height * 0.5
 Me.Left = Screen.Width * 0.5 - Width * 0.5