Public Class DlgBasesNum
  Private numeroActual As Integer

  Private Sub ctDato_TextChanged(sender As System.Object, e As System.Windows.Controls.TextChangedEventArgs)
    If ctDato.Text.Length = 0 Then Return

    Dim texto As String = ctDato.Text
    Dim baseNum As Integer = 0

    If btopDecimal.IsChecked = True Then
      baseNum = 10
    ElseIf btopOctal.IsChecked = True Then
      baseNum = 8
    ElseIf btopHex.IsChecked = True Then
      baseNum = 16
    End If

    Try
      numeroActual = Convert.ToInt32(texto, baseNum)
    Catch ex As FormatException
      If texto = "-" OrElse texto = "+" Then Return
      MessageBox.Show(ex.Message)
    Catch ex As Exception
      MessageBox.Show(ex.Message)
    End Try
  End Sub

  Private Sub btopDecOcHex_Checked(sender As System.Object, e As System.Windows.RoutedEventArgs)
    If btopDecimal.IsChecked = True Then
      ctDato.Text = Convert.ToString(numeroActual, 10)
    ElseIf btopOctal.IsChecked = True Then
      ctDato.Text = Convert.ToString(numeroActual, 8)
    ElseIf btopHex.IsChecked = True Then
      ctDato.Text = Convert.ToString(numeroActual, 16).ToUpper()
    End If
    ctDato.Focus()
  End Sub
End Class
