title: Center rectangle in another rectangle
body: <p>I have not been able to establish a really reliable code to center a rectangle in another rectangle.</p>
  
  <p>I would like to have the "RectangleToCenter"'s center point match the "SourceRectangle"'s center point.
  No scaling should be involved. </p>
  
  <p>My current attempt is</p>
  
  <pre><code>Public Sub CenterRect(ByVal uMain As Rectangle, ByRef uRectToCenter As Rectangle)
  
      Dim iAVHeightHalf As Integer = uMain.Height / 2 'src y center
      Dim iAVWidthHalf As Integer = uMain.Width / 2 'src x center
  
      Dim iStartDestX As Integer = uMain.Left + (uRectToCenter.Width / 2) - iAVWidthHalf
      Dim iStartDestY As Integer = uMain.Top + (uRectToCenter.Height / 2) - iAVHeightHalf
  
      Dim nNewStart As New Point(iStartDestX, iStartDestY)
  
      uRectToCenter.Location = nNewStart
  
  End Sub
  </code></pre>
  
  <p>But it does not look clean to me.</p>