Friday, April 8, 2011

Center the Form you

By default, when we try to create a form in Visual Basic 6 and run it, then the form that will open in a haphazard, usually on the left top corner. If we create applications with a professional looking, of course this is not good. We must arrange it with a good location, right in the middle of the screen for example. Well in this article I'll variety of functions that will make us form an open right in the middle of the screen. This function is very simple, we will move this form to the coordinates of the center of the screen.

The logic of this function is to take a screen width less the width of his past form in for 2. Of course it will make the left corner where the form will be in place the 'residual' empty space left and right of the form will have the same width. For high-form will also be in motion with the same calculation.

Well, here is the function form becomes.

Sub TengahkanPersis (f As Form)
'Center the form that you mean f.Move (Screen.Width - f.Width) \ 2, ((Screen.Height - (f.Height)) \ 2)

To use the form it, put it in the Form_Load procedure. So that form is open, TengahkanPersis function will be called and will put your form in the middle of the screen.

an example of this function call.

Private Sub Form_Load ()
'/ center the formTengahkanPersis Me'/ this line content with other functions.

Hopefully this article helpful.


Post a Comment