Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


changing the font size..

Posted on 1999-07-18
Medium Priority
Last Modified: 2013-12-02
how do i change the font size of all the objects on a form

without writing for each object "<object>.font.size=<size>"

Question by:amird
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
  • 2
LVL 12

Expert Comment

ID: 1525596
If you set the forms font size at design time then all controls will inherit that size as you add them.

You can also "lasso" a group of controls (or select all with <Ctrl A>) and change thier font as a group.

At runtime, you're going to have to iterate thru the Controls collection changing the fonts as you go. Not all controls support a font size so you'll need a little bypass logic to skip control types that don't support font size property. Basic loop will be:

dim ctrl as object

for each ctrl in controls
  ctrl.fontsize = whatever
next ctrl

If you're dynamically resizing a forms' controls as the user changes rez, this is generally not a good idea. If you're doing it in response to an operator controlled selection, then that is better.



Author Comment

ID: 1525597
there is still a problem with the size of the contols that doesnt changed accordingly to the change in the font size
LVL 12

Accepted Solution

mark2150 earned 30 total points
ID: 1525598
You didn't *ask* that! You asked: "how do i change the font size of all the objects on a form without writing for each object "<object>.font.size=<size>". You didn't mention resizing the objects!

Resizing, in theory, is not hard. You use a pair of const to remind your program of the Screen.Width and .Height that it was originally coded for. Then at runtime you compute the ratio of what you were originally set for to what you're running on right now. Iterate thru the controls and scale the .Left, .Top, .Width, and .Height appropriately.

Problem is that the users will generally perceive this behaviour as a *BUG* more than a *feature*. General opinion on "dynamic resize" is DON'T. The user is upping their rez to fit more on screen at once. If your program automatically grows to take more space this defeats the users wishes and is perceived as a *problem*.

Better to set minimum rez for your software to, say, 800x600 and make it look nice in that context. If the user pushes the rez to 1200,1024, ok, then that's *THEIR* choice and you'll still look nice with 800x600 screens.



Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question ( 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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

704 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