0

I need to be able to work with decimals. Right now I am trying to subract 2 decimals and it is not working

I input 10.89 in price and 11 in change the result should be 0.11, but I get 0.19999999

Why?

price As Double

Dim change As Double

Double.TryParse(Me.TPrice.Text, Price)

Double.TryParse(Me.TChange.Text, change)

Dim variable1 As double

variable1 = change - price



Me.LDollars.Text = Convert.ToString(variable1)

Edited by pyTony: fixed formatting

4
Contributors
4
Replies
5
Views
11 Years
Discussion Span
Last Post by arjunsasidharan
0

Maybe you are not converting the string to a double properly or you need to initialise variable1 to zero (at a guess).

Dim variable1 As Double
variable1 = 0
0

nope that did not work

Maybe you are not converting the string to a double properly or you need to initialise variable1 to zero (at a guess).

Dim variable1 As Double
variable1 = 0
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.