|
-
Oct 20th, 2001, 11:31 AM
#1
How to calc exactly length in pixel unit of any string
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.
-
Oct 20th, 2001, 11:40 AM
#2
Frenzied Member
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
Free VB Add-In - The Reference Librarian
Click Here for screen shot and download link.
-
Oct 20th, 2001, 11:50 AM
#3
Member
Also...
VB Code:
Me.Font.Name = "Arial"
Me.Font.Size = 12
.
.
.
-
Oct 20th, 2001, 12:01 PM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|