Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Automatic Text Resizing

Posted on 2000-03-16
9
Medium Priority
?
168 Views
Last Modified: 2010-05-02
I have a sizeable form which I want to write text on. The text must be within a Label, TextBox or PictureBox. When the form is manually resized, I want the text to resize too, so that it fills the entire form.  Any good solutions?
0
Comment
Question by:OTveit
[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
  • 6
  • 2
9 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 2623235
It ain't pretty but it works.

Option Explicit

Private Sub Form_Load()

ResizeLabel

End Sub

Private Sub Form_Resize()

ResizeLabel

End Sub

Private Sub Text1_Change()

Label1.Caption = Text1.Text
ResizeLabel

End Sub
Private Sub ResizeLabel()

Set Me.Font = Label1.Font

Me.Font.Size = 1000
Do While TextWidth(Label1.Caption) > ScaleWidth
    Me.Font.Size = Me.Font.Size / 1.3
Loop

Set Label1.Font = Me.Font

End Sub
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2623236
In the Form Resize event, do something like this:

   Text1.width = form1.width - 120
   Text1.height = text1.height - 360

You may need to adjust this if the top of text1 is not 0... for example:

   Text1.height = text1.height - 360 - text1.top

or something like that...


Cheers!®©
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2623237
PS - stick the label at position 0,0 and the text box relatively far down the form.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Accepted Solution

by:
caraf_g earned 150 total points
ID: 2623247
Here: this is a bit less flickery.

Option Explicit

Private Sub Form_Load()

ResizeLabel

End Sub

Private Sub Form_Resize()

ResizeLabel

End Sub

Private Sub Text1_Change()

Label1.Caption = Text1.Text
ResizeLabel

End Sub
Private Sub ResizeLabel()

Me.Font.Size = 1000
Do While TextWidth(Label1.Caption) > ScaleWidth
    Me.Font.Size = Me.Font.Size / 1.3
Loop

Label1.Font.Name = Me.Font.Name
Label1.Font.Size = Me.Font.Size

End Sub

I've done Font.Name and Font.Size. You can code the other font properties (bold, italic, etc.) yourself
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2623249
mcrider, you misunderstood. OTveit wants the actual text, not just the control, to fill the whole form.
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2623299
Yea, I think you're right...  It sounded like OTveit wanted the textbox (or whatever) to resize...


Cheers!®©
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2623372
No probs. I don't think my suggestion is elegant enough to qualify as an "answer" either... Ah well, if OTveit thinks it does he can always accept a comment ;-)
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2623579
Well? Any good?
0
 

Author Comment

by:OTveit
ID: 2628088
Yepp, it works ok. I just had to do the same for the height.

Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

609 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