VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Autosize a Label Caption

Geoff Temple  (1 Submission)   String Manipulation   Visual Basic 3.0   Intermediate   Wed 3rd February 2021

This small and very simple sub will format the caption of a Label control if the text is too big to display in the control. The sub will trucate the text and append "..." to the end of the text (indicating to the user that they are not seeing the full text). VB automatically wordwraps the caption of a label if it is too big, however, this results in the caption being truncated only where there is a space. Also, you can see the top of the next line of the caption.
Example
Make and Model: Cadillac
becomes:
Make and Model: Cadillac Eldor...
I find this extremely useful when I don't know the maximum length of the text the label will contain, or if I don't have enough screen real estate to make the Label big enough.
Just pass a label to this sub for formatting.

Inputs
A label control.

Rate Autosize a Label Caption (7(7 Vote))
Autosize a Label Caption.bas

Autosize a Label Caption Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters