Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rule of thumb for text boxes?

Status
Not open for further replies.

slwolf8

Technical User
Apr 23, 2001
82
US
Is there a guideline to help decide what width to make a text box to allow for a certain number of characters? Thanks.
 
Problem is, that will change when font/size are changed.

I once used an unusual workaround to find the width of a string in a certain font/size on the fly. I wrote a piece of code that:

Wrote the string to a cell in a hidden column on my worksheet, set the font/size properties of that cell to match, used the AutoFit function to adjust the width of the column, then returned the columns width as the value I wanted.

You might be able to do something similar. . .

VBAjedi [swords]
 
I mean a text box on a form, not in a worksheet, sorry!
 
A crude manual method would be to put the following string into a textbox in the Font and Size you plan to use, and size the textbox so the string just fits on one line:

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

Then divide the width of the textbox by 62 (the number of chars in the string) to get the average character width for that font.

Like I said, it's crude. . .

VBAjedi [swords]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top