Android Question NumberFormat2 not working quite as I expect

Discussion in 'Android Questions' started by barx, Apr 10, 2015.

  1. barx

    barx Well-Known Member Licensed User

    I'm wanting to show a number in an Edittext as x.xx with 2 decimal point values shown all the time
    e.g 1.00, 0.96, 0.90, etc

    With the following code I get:
    1.0, 0.99, 0.98, 0.97, 0.96, 0.95, 0.94, 0.93, 0.92, 0.91, 0.9, .......


    Code:
    Sub btnShadeDown_Click
           
    If txtShade.Text > 0 Then
             
    Dim NewShade As Double = NumberFormat2((txtShade.Text - 0.01), 022False)
             
    Log(NewShade)
             txtShade.Text = NewShade
           
    End If
         
    End Sub
    How comes 2 decimal places are not show each time?

    Thanks
     
  2. DonManfred

    DonManfred Expert Licensed User

    Code:
    Sub btnShadeDown_Click
           
    If txtShade.Text > 0 Then
             
    Dim NewShade As Double =  (txtShade.Text - 0.01)
             
    Log(NumberFormat2(NewShade, 022False))
             txtShade.Text = 
    NumberFormat2(NewShade, 022False)
           
    End If
         
    End Sub
     
    lemonisdead and barx like this.
  3. barx

    barx Well-Known Member Licensed User

    Ah yes, silly me.

    My Head is mushy peas this morning. Not thinking straight at all. Thanks @DonManfred
     
    DonManfred likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice