Ver Mensaje Individual
  #12 (permalink)  
Antiguo 20/07/2010, 13:00
Avatar de Highlander
Highlander
 
Fecha de Ingreso: junio-2006
Ubicación: Concepción, Chile
Mensajes: 475
Antigüedad: 17 años, 10 meses
Puntos: 4
Respuesta: Validar Precio

Muchas gracias amigos ya lo solucione con su ayuda, use el siguente codigo con una pequeña modificación mia ya que sino se cae en alguns situaciones.

Código:
  Private Sub TxtPrecioNeto_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtPrecioNeto.Validating

        Dim currency As Decimal
        'Convert the current value to currency, with or without a currency symbol.

        If Not Decimal.TryParse(Me.txtPrecioNeto.Text, Globalization.NumberStyles.Currency, Nothing, currency) Then

            'Don't let the user leave the field if the value is invalid.

            With Me.txtPrecioNeto

                .HideSelection = False
                .SelectAll()

                MessageBox.Show("Por favor ingrese un valor numerico.", "Valor Invalido", MessageBoxButtons.OK, MessageBoxIcon.Error)

                .HideSelection = True

            End With

            e.Cancel = True
        End If

    End Sub

 Private Sub TxtPrecioNeto_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPrecioNeto.Validated

        'Display the value as local currency.
        Me.txtPrecioNeto.Text = Decimal.Parse(Me.txtPrecioNeto.Text.Replace("$", "")).ToString("c")

    End Sub
__________________
Ingeniero (E) en Computación e Informática
The last man alone with god.