| 
            
           | 
          
            | 
          
          
          
          
            
              
              
                
                  | Title | Size a TextBox to fit its contents |  
                  | Keywords | TextBox, size, fit, resize |  
                  | Categories | Controls |  
                 
               |  
              
               
  |  
              | 
Make sure the form's font matches the TextBox's (or use a hidden PictureBox control). Use the form's TextWidth and TextHeight methods to see how much room the text needs. Then size the TextBox accordingly, allowing a little extra room for the TextBox's borders.
               |  
              
               
  |  
              
                
                  ' Make the TextBox fit its contents.
Private Sub FitTextBoxContents(ByVal txt As TextBox)
    Font = Text1.Font
    txt.Width = TextWidth(txt.Text) + 120
    txt.Height = TextHeight(txt.Text) + 120
End Sub
               |  
              
              
              
              |   |  
               
 |  
              |   |  
              
           |  
          
          
          
          
             
           |