Originally posted by Spajeoly
Isn't there a property for the text box to have all the text centered?
Horizontally? Yes
Vertically? No

I wrote some code this morning to center the text box itself instead of the text. I've been testing it for a bit and so far I really like the results. The textbox is borderless, so it looks to the end user like the text just centers when they move off the text box.

VB Code:
  1. Option Explicit
  2.  
  3. Private Declare Function SendMessage Lib "user32" _
  4.    Alias "SendMessageA" _
  5.   (ByVal hwnd As Long, _
  6.    ByVal wMsg As Long, _
  7.    ByVal wParam As Long, _
  8.    lParam As Any) As Long
  9.  
  10. Private Const EM_GETLINECOUNT = &HBA
  11. Private Const TEXT_HEIGHT = 210
  12.  
  13. Private Sub UserControl_Resize()
  14.     ResizeControls
  15. End Sub
  16. Private Sub txtDescription_GotFocus()
  17.     'hightlight text
  18.     txtDescription.SelStart = 0
  19.     txtDescription.SelLength = Len(txtDescription.Text)
  20.     'make description full size while it has focus
  21.     ResizeDescription
  22. End Sub
  23. Private Sub txtDescription_LostFocus()
  24.     'make sure beginning text is visible
  25.     txtDescription.SelStart = 0
  26.     txtDescription.SelLength = 0
  27.     ResizeControls
  28. End Sub
  29. Private Sub ResizeDescription()
  30.     txtDescription.Top = UserControl.ScaleTop
  31.     txtDescription.Width = UserControl.ScaleWidth - 60
  32.     txtDescription.Left = 30
  33.     txtDescription.Height = txtUtensil.Top - txtDescription.Top
  34. End Sub
  35.  
  36. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
  37. 'MappingInfo=UserControl,UserControl,-1,Refresh
  38. Public Sub Refresh()
  39.     UserControl.Refresh
  40.     ResizeControls
  41. End Sub
  42. Private Sub ResizeControls()
  43.    
  44.     txtUtensil.Left = 50
  45.     txtUtensil.Top = UserControl.ScaleTop + UserControl.ScaleHeight - txtUtensil.Height - 5
  46.     txtUtensil.Height = UserControl.TextHeight(txtUtensil.Text) - 50
  47.     txtUtensil.Width = UserControl.ScaleWidth - 100
  48.    
  49.     txtDescription.Width = UserControl.ScaleWidth - 60
  50.     txtDescription.Left = 30
  51.     txtDescription.Height = GetLines(txtDescription) * TEXT_HEIGHT
  52.     txtDescription.Top = (txtUtensil.Top - txtDescription.Height) / 2
  53.  
  54. End Sub
  55. Private Function GetLines(txt As TextBox) As Long
  56.     GetLines = SendMessage(txt.hwnd, EM_GETLINECOUNT, 0&, ByVal 0&)
  57. End Function