title: Validating textbox when enter button is pushed
body: <p>I'm creating a AddIn for Autodesk Inventor (3D drawing software), and for the moment I am playing with positional constraints.</p>
  
  <p>I created a custom user menu for quick editing certain values, in this case the elevation and orientation value.</p>
  
  <p>First I used the <code>textbox.textchanged</code> event to change my constraint value. But this was working not 100%. Example when pressing elevation 1000 would change the elevation 4 times ( on per digit ).</p>
  
  <p>Now I went to using the <code>validated event</code>. This works better, BUT I would like to have the textbox to initiate validation when the <code>Enter</code> button is pressed. For this I whipped up this, but it's not correct i'm sure of it. How should I write this correctly?</p>
  
  <p>The code below works but, I would like to have a proper way to achieve the result.</p>
  
  <pre><code>Private Sub tbElevationValue_TextChanged(sender As Object, e As EventArgs) _
      Handles tbElevation.Validated
  
      ' If the elevation parameter and textbox value are the same
      ' The sub must be aborted
      If CDbl(tbElevation.Text) = oElevationParameter.Value * 10 Then Exit Sub
  
      ' Check the entered value
      Dim oValue As Double
      If tbElevation.Text = "" Then
          oValue = 0
          tbElevation.Text = 0
      Else
          oValue = tbElevation.Text
      End If
  
      ' Set the parameter value
      oElevationParameter.Value = oValue / 10
  
      ' Update the document
      EM_AddIn.StandardAddInServer.m_inventorApplication.ActiveDocument.Update()
  
  End Sub
  
  Private Sub tbOrientation_TextChanged(sender As Object, e As EventArgs) _
      Handles tbOrientation.Validated
  
      ' If the orientation parameter and textbox value are the same
      ' The sub must be aborted
      If CDbl(tbOrientation.Text) = cRandiansToDegrees(oOrientationParameter.Value) Then Exit Sub
  
      ' Check the entered value
      Dim oValue As Double
      If tbOrientation.Text = "" Then
          oValue = 0
          tbOrientation.Text = 0
      Else
          oValue = tbOrientation.Text
      End If
  
      ' Set the parameter value
      oOrientationParameter.Value = cDegreesToRandians(oValue)
  
      ' Update the document
      EM_AddIn.StandardAddInServer.m_inventorApplication.ActiveDocument.Update()
  
  End Sub
  
  Private Sub OrientationElevationEnterKey_Pressed(sender As Object, e As Windows.Forms.KeyEventArgs) Handles tbElevation.KeyUp, tbOrientation.KeyUp
  
      If e.KeyCode = Windows.Forms.Keys.Enter Then
  
          CType(sender, Windows.Forms.TextBox).Parent.Focus()
          CType(sender, Windows.Forms.TextBox).Focus()
  
      End If
  
  
  End Sub
  </code></pre>