Hello u guys!
Do u know how to calc exactly length in pixel unit of any given string? I tried to use GetCharWidth and GetTextMetrics but can not get exactly length of string.
Printable View
Hello u guys!
Do u know how to calc exactly length in pixel unit of any given string? I tried to use GetCharWidth and GetTextMetrics but can not get exactly length of string.
You can use the TextWidth method of a Form or Picture box provided the ScaleMode is vbPixels. If you want to get the Width of text in a label or something just make sure the Font name, size, etc are the same for the form and what ever other object you are trying to get the text width for.
VB Code:
Me.ScaleMode = vbTwips Debug.Print Me.TextWidth("Hello world") Me.ScaleMode = vbPixels Debug.Print Me.TextWidth("Hello world")
Greg
Also...
VB Code:
Me.Font.Name = "Arial" Me.Font.Size = 12 . . .
Quote:
Originally posted by gdebacker
You can use the TextWidth method of a Form or Picture box provided the ScaleMode is vbPixels. If you want to get the Width of text in a label or something just make sure the Font name, size, etc are the same for the form and what ever other object you are trying to get the text width for.
VB Code:
Me.ScaleMode = vbTwips Debug.Print Me.TextWidth("Hello world") Me.ScaleMode = vbPixels Debug.Print Me.TextWidth("Hello world")
Greg
Yeah, it seem to be good for me. Thanks for ur help.