VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Place an Object in the Center of your Screen

by Jeffrey C. Tatum (5 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

This will take an object on a form, and place it in the center of the screen. Good for password protection programs that take up the whole screen, this will ensure that an object that you want in the middle of the screen, will remain there for any resolution.

Rate Place an Object in the Center of your Screen

'Place this in a module for use in the future:
Public Sub Object_Center(Frm As Form, Cntrl As Object)
'To call it, you would simply do:
'Call Object_Center(Form1, Text1)
'and that will center Text1 in the middle of your
'screen, no matter how big, or where Form1 is
Cntrl.Top = (Screen.Height * 1#) / 2 - Cntrl.Height / 2
Cntrl.Left = (Screen.Width * 1#) / 2 - Cntrl.Width / 2
End Sub

Download this snippet    Add to My Saved Code

Place an Object in the Center of your Screen Comments

No comments have been posted about Place an Object in the Center of your Screen. Why not be the first to post a comment about Place an Object in the Center of your Screen.

Post your comment

Subject:
Message:
0/1000 characters