Labels, and more

the_manic_mouse
09-08-2003, 07:58 PM
Hi, I don't know if this can be done, but I'm hoping that someone out there will know how to do this.

How can I auto resize a label to fit the text

e.g. if the label is 14 chars or less resize to the size of the text
if it's more seperate by word on to 2 rows

i.e.
Hello World

Hello World
Program

Like on the Desktop Icons

I just think it looks better

passel
09-08-2003, 08:45 PM
You can try something like this.

Private Sub Command1_Click()
a$ = "Hello World Program"
If Len(a$) > 14 Then
Label1.Autosize = False
Label1.Width = Me.TextWidth(Left$(a$, 14))
Else
Label1.AutoSize = True
End If
Label1.Caption = a$
End Sub

DroopyPawn
09-08-2003, 08:57 PM
The Label control has an Autosize property that will resize itself for one-row text. That woun't help for 2 row text though. However, if you include vbCrLf in the text, that with the Autosize property might help.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum