Class MainWindow 
  Private objTextBox As TextBox = Nothing

  Private Sub btAceptar_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    Try
      Dim grados As Double
      ' Si se escribió en la caja de texto grados centígrados...
      If objTextBox Is ctGradosC Then
        grados = Convert.ToDouble(ctGradosC.Text) * 9.0 / 5.0 + 32.0
        ' Mostrar el resultado redondeado a dos decimales
        ctGradosF.Text = String.Format("{0:F2}", grados)
      End If
      ' Si se escribió en la caja de texto grados Fahrenheit...
      If objTextBox Is ctGradosF Then
        grados = (Convert.ToDouble(ctGradosF.Text) - 32.0) * 5.0 / 9.0
        ' Mostrar el resultado redondeado a dos decimales
        ctGradosC.Text = String.Format("{0:F2}", grados)
      End If
    Catch exc As FormatException
      ctGradosC.Text = "0,00"
      ctGradosF.Text = "32,00"
    End Try
  End Sub

  Private Sub ctGradosC_PreviewTextInput(sender As System.Object, e As System.Windows.Input.TextCompositionEventArgs)
    objTextBox = TryCast(sender, TextBox)
  End Sub

  Private Sub ctGradosF_PreviewTextInput(sender As System.Object, e As System.Windows.Input.TextCompositionEventArgs)
    objTextBox = TryCast(sender, TextBox)
  End Sub

  Private Sub formPrincipal_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctGradosC.Focus()
  End Sub

  Private Sub ctGrados_GotKeyboardFocus(sender As System.Object, e As System.Windows.Input.KeyboardFocusChangedEventArgs)
    Dim ObjTextBox As TextBox = TryCast(sender, TextBox)
    ObjTextBox.SelectAll()
  End Sub
End Class
