Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/07/2011, 14:15
guillebomtrasmiti
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 6 meses
Puntos: 5
Pregunta restar un decimal

hola amigos, tengo una grilla y un campo decimal...
el problema es que en un textbox guardo una cifra...y cuando esta tiene
decimales ni me la suma ni me la resta a la grilla...en cambio si la cifra
es redonda lo hace a la perfección....os mando el código

Dim tod As Decimal = 0
'For i = 0 To DgGenerados.Rows.Count - 1
tod = CDec(CDbl(TextCifraFinal.Text) - CDbl(TextImporte.Text))
TextDif.Text = CStr(tod)
Dim todo As Decimal = 0
'For i = 0 To DgGenerados.Rows.Count - 1
todo = CDec(((todo + Val(DgGenerados.CurrentRow.Cells(6).Value) - CDbl(TextDif.Text))))

Dim adapt As New OleDbDataAdapter
Dim setda As New DataSet
Dim com = conexion.CreateCommand

com.CommandType = CommandType.Text
com.CommandText = "UPDATE HistoricoTickets SET Euros = (" & todo & ") where Euros = @FI and Id = @FA"

com.Parameters.AddWithValue("@FI", DgGenerados.CurrentRow.Cells(6).Value)
com.Parameters.AddWithValue("@FA", DgGenerados.CurrentRow.Cells(0).Value)

adapt.UpdateCommand = com
conexion.Open()
com.ExecuteNonQuery()
conexion.Close()
frmProgressbar.Close()
Catch