Results 1 to 3 of 3

Thread: Resizing a picture box to contain text

  1. #1
    james007lamb
    Guest

    Question Resizing a picture box to contain text

    i have a picture box, in which i print a lot of text lines. Basically the number of lines i print depends on a variable!

    I want the picbox to resize in height so that it can contain all those text lines, but don't know how to do it????

    e.g. if i know that i have 20 lines how do i change the size??? (the font size is at the default!!)

    Please help!!!

    James

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. Private Sub Command2_Click()
    2.     Dim sVar As String
    3.     sVar = "some lines of text"
    4.     Picture1.Height = Picture1.TextHeight(sVar) * 20
    5. End Sub

    u have to add some height in order to make this correct
    -= a peet post =-

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    a bit confusing the last post ... sorry about that...

    sample

    VB Code:
    1. Private Sub Command2_Click()
    2.     Dim sVar As String
    3.     Dim i As Integer
    4.     For i = 0 To 19
    5.         sVar = sVar & "some lines of text " & i & vbCrLf
    6.     Next i
    7.     Picture1.Height = Picture1.TextHeight(sVar)
    8.     Picture1.Print sVar
    9. End Sub
    -= a peet post =-

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