Solved

Centred text on form

Posted on 2000-05-08
9
192 Views
Last Modified: 2011-04-14
I am trying to develop a form that displays text.  However due to the nature of the form many situation will need to resize the form depending .

I want to keep the text in the centre of the form after the size of the form has been altered.

any ideas how to do this?
0
Comment
Question by:traderSPT
[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
9 Comments
 
LVL 6

Expert Comment

by:setiawan
ID: 2788003
Hi traderSPT,

What do you want to use ?
I assume you use labet to display text.

lbl1.left = (Form1.Width - Len(lbl1.text)) div 2
lbl1.heigh = Form1.Heigh div 2

hope this helps

  danny
0
 
LVL 18

Expert Comment

by:deighton
ID: 2788011
Call centre(Text1)



Private Sub centre(x As Object)

    x.Left = Form1.ScaleWidth / 2 - x.Width / 2
    x.Top = Form1.ScaleHeight / 2 - x.Height / 2


End Sub
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2788016
Yes, more or less correct. Except I would use ScaleWidth rather than Width for the form. And ScaleHeight. Make sure your form's ScaleMode remains as default: Twips.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Expert Comment

by:caraf_g
ID: 2788018
hehe. pipped at the post ;-)
0
 
LVL 18

Accepted Solution

by:
deighton earned 50 total points
ID: 2788235
Call centre(Text1)



                    Private Sub centre(x As Object)

                        x.Left = Form1.ScaleWidth / 2 - x.Width / 2
                        x.Top = Form1.ScaleHeight / 2 - x.Height / 2


                    End Sub
0
 
LVL 15

Expert Comment

by:ameba
ID: 2788444
>in the centre of the form after the size of the form has been altered.

One solution can be to put deighton's code in the Resize event of the form.

Private Sub Form_Resize()
    Call centre(Text1)
End Sub
0
 

Author Comment

by:traderSPT
ID: 2788544
Many Thanks for the help I had the scalewidth height etc sorted but couldnt get it to update the form once it was running.

0
 
LVL 18

Expert Comment

by:deighton
ID: 2788646
You should perhaps have awarded ameba the question, since his info was what you needed.  
0
 

Expert Comment

by:trick_jc
ID: 2789435
Use the RESIZE event of the form and use a label for displaying your text.

Private Sub Form_Load()
    Call Form_Resize
End Sub

Private Sub Form_Resize()

Label1.Top = (Me.Height / 2) -   (Label1.Height / 2)
Label1.Left = (Me.Width - Label1.Width) / 2

End Sub
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month4 days, 7 hours left to enroll

636 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