Anyone knows how to find out the width of a specific character or some text when using a non-preformatted font? For example: the "i" takes up less pixels then the "w".
Although there are API calls to allow you to do this you don't need them in VB. Form's have a TextWidth property. So. for example, just have a hidden form with it's scalemode set to pixels and then something like the following: [tt]
Option Explicit
Private Sub Command1_Click()
Debug.Print GetTextPixelWidth("i", Text1)
End Sub
Private Function GetTextPixelWidth(strText As String, SourceControl As Control) As Single
Set HiddenForm.Font = SourceControl.Font
GetTextPixelWidth = HiddenForm.TextWidth(strText)
End Function
Thanx, I never knew..
I stayed up all night eating too much pizza and neglecting my girlfriend, figuring out a way (using an enormous amount of code), while the answer was so easy!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.