Solved

Centred text on form

Posted on 2000-05-08
9
190 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
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

831 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