stretching a textbox

G

Guest

Is it possible to take a textbox and have it expand to a new length depending
on the length of the info in it? I could have company names show in a
textbox as short as 3 letters to one that would have 24 letters (or any new
ones that might be longer). The info in the txtbox would be placed there
from a combobox selection.
Thanks in advance to anyone who responds.
*** John
 
M

Marshall Barton

JohnE said:
Is it possible to take a textbox and have it expand to a new length depending
on the length of the info in it? I could have company names show in a
textbox as short as 3 letters to one that would have 24 letters (or any new
ones that might be longer). The info in the txtbox would be placed there
from a combobox selection.


Yes, it's possible, but the code to determine the length of
the text is extremely complex. Fortunately, Stepehen Lebans
worked it out in his TextHeightWidth function at
www.lebans.com. I think you would use it something like
this:
Me.txtbox.Width = FTextWidth(Me.txtbox)

On the other hand, why bother? If your form has enough
real estate to accomodate a wider text box, why not just
make it wider in the design and not worry about the shorter
names that don't fill the text box?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top