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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Label problem

Status
Not open for further replies.

selimsl

Programmer
Aug 15, 2005
62
TR
Hi!

I have a label control.The DimensionS of label control are
height=480 and
width=384 for per letter.I mean that the height of the label control is fixed but width of the label control can change.go as follows

label1.width=len(label1.caption)*384

But depending of the font I have chosen,the text can't fill all of the label control.

The problem is that ,for each character I type,the space left after each letter adds up to fill too much space on the screen.

For example when I type 6 letters,there must not be any blank.The text must fill the label control

Thanks in advice...




 
Why not just set the Autosize property to True

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
I have to use this formula

label1.width=len(label1.caption)*384

That why I can't use autosize property

Do you have any other solution

Thanks in advice

 
I have to use this formula
Why? Is this homework?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
johnwm was suggesting that you use the AutoSize property instead of the formula. It will be more accurate.

To see this in action, start up a new vb project. Add a text box control and a label control. Then put this code in.

Code:
Option Explicit

Private Sub Form_Load()
    
    Label1.AutoSize = True
    Label1.BorderStyle = 1
    
End Sub

Private Sub Text1_Change()
    
    Label1.Caption = Text1.Text
    
End Sub

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
selimsl,

If you have to use formula that doesn't work, how can we help?

vladk
 
Hi selimsl:

If you can't use John's suggestion, how about:
Code:
Private Sub Label1_Change()
    Label1.Width = TextWidth(Label1.Caption)
End Sub



Cassie
PIII-500Mhz-128MB
Win98SE-VB6SP5
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top