Código
Public Class Form1 Private Inicializado As Boolean Private Sub txtBillete50_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBillete50.TextChanged, txtBillete20.TextChanged, txtBillete10.TextChanged, txtBillete5.TextChanged, txtMonedas2.TextChanged, txtMonedas1.TextChanged, txtMonedas050.TextChanged, txtMonedas020.TextChanged, txtMonedas010.TextChanged, txtMonedas005.TextChanged, txtMonedas002.TextChanged, txtMonedas001.TextChanged sender.backcolor = Color.White txtTotal.Visible = True End Sub Private Sub txtBillete50_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtBillete50.Validated, txtBillete20.Validated, txtBillete10.Validated, txtBillete5.Validated, txtMonedas2.Validated, txtMonedas1.Validated, txtMonedas050.Validated, txtMonedas020.Validated, txtMonedas010.Validated, txtMonedas005.Validated, txtMonedas002.Validated, txtMonedas001.Validated sender.backcolor = Color.White txtTotal.Visible = True End Sub Private Sub txtBillete50_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtBillete50.Validating Dim v As UShort 'UInt16 entero de 16 bits (valor en el rango: 0-65536) ' si admite un valor negativo, cambia al tipo short (int16) If UShort.TryParse(txtBillete50.Text, v) = False Then e.Cancel = True Call MessageBox.Show("No puede tomarse como un numero el valor para 'billete de 50'.", "Error: No es un numero.", MessageBoxButtons.OK, MessageBoxIcon.Warning) 'txtImporte50.Text ="0" Else txtImporte50.Text = (v * 50).ToString End If End Sub Private Sub txtBillete20_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtBillete20.Validating Dim v As UShort If UShort.TryParse(txtBillete20.Text, v) = False Then e.Cancel = True Call MessageBox.Show("No puede tomarse como un numero el valor para 'billete de 20'.", "Error: No es un numero.", MessageBoxButtons.OK, MessageBoxIcon.Warning) Else txtImporte20.Text = (v * 20).ToString End If End Sub Private Sub txtBillete10_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Dim v As UShort If UShort.TryParse(txtBillete10.Text, v) = False Then e.Cancel = True Call MessageBox.Show("No puede tomarse como un numero el valor para 'billete de 10'.", "Error: No es un numero.", MessageBoxButtons.OK, MessageBoxIcon.Warning) Else txtImporte10.Text = (v * 10).ToString End If End Sub Private Sub Totalizar() Handles txtImporte50.TextChanged, txtImporte20.TextChanged, txtImporte10.TextChanged Dim CantidadTotal As Single ' entero de 32 bits... If (Inicializado = True) Then CantidadTotal = 0 CantidadTotal += Single.Parse(txtImporte50.Text) CantidadTotal += Single.Parse(txtImporte20.Text) CantidadTotal += Single.Parse(txtImporte10.Text) txtTotal.Text = CantidadTotal.ToString End If End Sub