Results 1 to 3 of 3

Thread: text length in twips

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092
    can you get that value some how?

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    if you have a form or picturebox handy then it's easy

    Code:
    Dim sngTextWidth As Single  'Width of text in whatever scalemode your form's in
    Dim sngTextWidthTwips As Single 'width of text in twips
    
    'Get the width of the form in some scalemode
    sngTextWidth = Form1.TextWidth("Hello")
    
    'Convert to twips
    sngTextWidthTwips = Form1.ScaleX(sngTextWidth, Form1.ScaleMode, vbTwips)
    
    MsgBox """Hello"" is " & sngTextWidthTwips & " Twips Wide."
    hope it helps

  3. #3
    Guest
    Don't forget to set the form or picturebox font to the same font as the text you want to measure.

    The other option is to use the GetTextExtent32 API call, but you still need a device context and a handle to a font object.

    - gaffa

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width