Solved

How to open a form centered?

Posted on 2002-07-26
5
157 Views
Last Modified: 2010-05-02
How do I make sure a form opens in the center of my screen?  Thanks
0
Comment
Question by:InvisibleMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 7179872
Set the forms StartUpPosition to  'CenterScreen'
0
 
LVL 4

Accepted Solution

by:
ChenChen earned 25 total points
ID: 7179917
Two ways:
1. add these two lines in the Sub form_load:
    me.left=(screen.width-me.width)/2
    me.top=(screen.height-me.height)/2

2. set StartUpPosition property to 'CentreScreen'

0
 
LVL 3

Expert Comment

by:sanjaykattimani
ID: 7180046
Above 2 ways you can centre the screen,
Make sure that once you set the startupPosition property, you do not drag the window or change the position [that resets the startupPosition property]
0
 
LVL 2

Expert Comment

by:vbPhil
ID: 7180290
I agree with the above, but I also like to keep the form invisible, until it is sized and/or centered.

Set Visible = False

in the Form_Load() event

'Size it first if necessary...

Me.Left = (Screen.Width - Me.width) / 2
Me.Top = (Screen.Height - Me.height) / 2

Doevents
Me.Show

This makes sure all of the moving around is finished before the user sees it.

0
 

Author Comment

by:InvisibleMan
ID: 7181095
Can someone give me a function or sub I could call to make sure they open in center view?  Thanks. This way I can pass in a form.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month5 days, 13 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question