Results 1 to 3 of 3

Thread: length of text in textbox for any font

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    Florida
    Posts
    45

    Talking length of text in textbox for any font

    Hi All,

    Using VB 6 I want to find out the length of text (in twips?) in a textbox regardless of which font is being used (not a count of characters).

    I've tried both

    GetTabbedTextExtent()

    and

    GetTextExtentPoint32()

    but they both return 0 even though I can see that there are characters in the textbox.

    Thank you.
    If I could only remember my name...

  2. #2
    Member Stef's Avatar
    Join Date
    May 2001
    Posts
    41
    Try:
    Code:
    TxtWidth = TextWidth(Text1.Text)
    You might need to set the form's font property to match your textbox's font, and its scalemode to the scale you want (twips/pixels/???)

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    Florida
    Posts
    45

    Thumbs up length of text in textbox for any font

    That seems to do it. I did set the form's properties as you suggested. I tried setting the text box width based on the TextWidth of it's content and I had to add to add another 100 twips for all the text to display. For option button captions I had to add another 295.

    This is interesting and thank you for pointing me in this direction.
    If I could only remember my name...

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