Results 1 to 4 of 4

Thread: Centering a form in a one line statement?

  1. #1
    Guest

    Question

    I have been using this to center forms:

    Code:
    myform.left = (Screen.Width - myform.Width) / 2
    myform.top = (Screen.Height - myform.Height) / 2
    I have seen somewhere where they explained how to center the form with only one line of code. Anyone know how? I can't find the site anywhere.



  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    This seems to work for me:
    Code:
    Form1.Move (Screen.Width - Form1.Width) / 2, (Screen.Height - Form1.Height) / 2

  3. #3
    Guest
    That was it, move.
    Thanks a lot

  4. #4
    Addicted Member LAURENS's Avatar
    Join Date
    Jan 2000
    Location
    Utrecht, the Netherlands
    Posts
    138
    Forms in VB6 have a StartupPosition Property which you can set to 2 (= CenterScreen).

    Of course, as the name of the property implies, this only works when the form starts.

    Regards,
    Laurens

    Using VB5 Enterprise edition SP3
    VB6 Enterprise edition SP5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width