Results 1 to 3 of 3

Thread: VB 2010 TextWidth

  1. #1

    Thread Starter
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    VB 2010 TextWidth

    Hi, i'm just out of vb6 and i'm wondering how to do what previously in vb6 was TextWidth. This is an essential function for positioning strings so i need it a lot. I looked through all the things but i didn't find anything. Probably it's the same function under a different name, how is this done?
    Hooked for good.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,466

    Re: VB 2010 TextWidth

    the graphics class has a measurestring method:

    vb Code:
    1. Dim gr As Graphics = Me.CreateGraphics
    2. Dim textSize As SizeF = gr.MeasureString("String", Me.Font)
    3. MsgBox(textSize.Width)

  3. #3

    Thread Starter
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    Re: VB 2010 TextWidth

    Thanks for the help. I know that was probably so simple that you wrote the reply to me with your eyes shut but i'm still new enough to 2010 that i really appreciated it. Thanks a lot!
    Hooked for good.

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