Results 1 to 7 of 7

Thread: [RESOLVED] Move Form1

  1. #1

    Thread Starter
    Addicted Member Garrett19212's Avatar
    Join Date
    Jan 2005
    Location
    US
    Posts
    220

    Resolved [RESOLVED] Move Form1

    How can I change the position of form1 on the screen with code.

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Move Form1

    Form1.left=500, form1.top=500

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Move Form1

    If you intend to change both the X and Y coordinate it is better to set the Location property rather than the Top and Left individually, which is actually visible to the user, e.g.
    VB Code:
    1. form1.Location = New Point(500, 500)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Addicted Member Garrett19212's Avatar
    Join Date
    Jan 2005
    Location
    US
    Posts
    220

    Re: Move Form1

    Thank you!

  5. #5

    Thread Starter
    Addicted Member Garrett19212's Avatar
    Join Date
    Jan 2005
    Location
    US
    Posts
    220

    Re: [RESOLVED] Move Form1

    Well its marked as resolved already, but I don't want to start a new thread for the same issue.
    VB Code:
    1. Form1.Left = Form1.Left + 200
    2. Form1.Top = Form1.Top + 200
    Why is that not working.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] Move Form1

    I'm going to guess that "Form1" is the name of a class. These are instance members, which means that you can only change their values for a specific instance of Form1, e.g.
    VB Code:
    1. Dim myForm1 As New Form1
    2.  
    3. myForm1.Left += 200
    4. myForm1.Top += 200
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] Move Form1

    If you want to use any members of the current instance you qualify them with "Me", e.g.
    VB Code:
    1. Me.Left += 200
    2. Me.Top += 200
    Strictly speaking the "Me." is not required, but it is good practice to include it for clarity and it means you get help from Intellisense as well.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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