PROBLEMA CON DECIMALES (2)
Publicado por edgardo (17 intervenciones) el 01/09/2020 16:29:42
Hola gente: estoy programando en VB:net 2010 como lo dije en otro mensaje y tengo la siguiente duda:
tengo 5 textbox con nombres
Tcan : es la cantidad (valor 1)
Tpu: precio unitario (valor 12.53)
Tdes: porcentaje de descuento valor ( 10.5)
Tdescpesos: total de descuento en valores valor(1.32)
Ttotal: total gral valor ( la gran duda.....)
ahora hago los cálculos y hay uno que da bien y el resto mal y NO SE PORQUE SI ALGUIEN ME DICE COMO TRABAJA ESTE VB, SE LO AGRADEZCO (era tan fácil en clipper ......)
TODO ESTO DENTRO DE ESTE CODIGO:
tengo 5 textbox con nombres
Tcan : es la cantidad (valor 1)
Tpu: precio unitario (valor 12.53)
Tdes: porcentaje de descuento valor ( 10.5)
Tdescpesos: total de descuento en valores valor(1.32)
Ttotal: total gral valor ( la gran duda.....)
ahora hago los cálculos y hay uno que da bien y el resto mal y NO SE PORQUE SI ALGUIEN ME DICE COMO TRABAJA ESTE VB, SE LO AGRADEZCO (era tan fácil en clipper ......)
1
2
3
4
5
Ttotal.Text = (Val(Tcan.Text) * Val(Tpu.Text)) - Val(TDescpesos.Text) ' DA MAL $ 11.53 ....
Ttotal.Text = (Val(Tcan.Text) * Val(Tpu.Text)) - CType((TDescpesos.Text), Double) ' DA BIEN 11.21
Ttotal.Text = (CType((Tcan.Text), Double) * CType((Tpu.Text), Double)) - CType((TDescpesos.Text), Double) ' DA MAL 1251.68
TODO ESTO DENTRO DE ESTE CODIGO:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Private Sub Tdes_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tdes.TextChanged
TDescpesos.Text = Math.Round((Val(Tpu.Text) * Val(Tdes.Text)) / 100, 2)
''' DA MAL
'Ttotal.Text = (Val(Tcan.Text) * Val(Tpu.Text)) - Val(TDescpesos.Text)
''' DA BIEN
'Ttotal.Text = (Val(Tcan.Text) * Val(Tpu.Text)) - CType((TDescpesos.Text), Double)
'''' MAL
Ttotal.Text = (CType((Tcan.Text), Double) * CType((Tpu.Text), Double)) - CType((TDescpesos.Text), Double)
End Sub
Valora esta pregunta


0