title: Justify the text in a richtextbox
body: <p>I know how to justify right center and left in both the text box and richtextbox, what I searched and found no answer for is Can you JUSTIFY the text just like in word or all those other programs? I tried using word pad then copied it and that worked fine it's just that when I wan't to be able to click a command button and justify the text so that the lines all line up i'm stopped,
  The code I am using is right here</p>
  
  <pre><code>    Option Explicit
  
  Private Const WM_USER As Long = &amp;H400&amp;
  Private Const EM_GETOLEINTERFACE As Long = WM_USER + 60
  Private Const EM_SETTYPOGRAPHYOPTIONS As Long = WM_USER + 202
  Private Const TO_ADVANCEDTYPOGRAPHY As Long = 1
  
  Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" ( _
      ByVal hWnd As Long, _
      ByVal wMsg As Long, _
      ByVal wParam As Long, _
      ByVal lParam As Long) As Long
  
  Private Document As tom.ITextDocument
  
  Private Sub cmdJustify_Click()
      'Justify the text of the first paragraph:
  
      'Select first paragraph in the document.
      With Document.Range(0, 0)
          .MoveEnd tomParagraph, 1
          .Para.Alignment = tomAlignJustify 'Apply justification.
          .Collapse tomStart 'Collapse the selection.
      End With
  End Sub
  
  Private Sub Form_Load()
      Dim Unknown As Object
  
      SendMessage rtb.hWnd, EM_GETOLEINTERFACE, 0, VarPtr(Unknown)
      Set Document = Unknown
      SendMessage rtb.hWnd, _
                  EM_SETTYPOGRAPHYOPTIONS, _
                  TO_ADVANCEDTYPOGRAPHY, _
                  TO_ADVANCEDTYPOGRAPHY
  
      rtb.LoadFile "Resources\Sample1.rtf"
  End Sub
  </code></pre>