Android Question double decimal

Discussion in 'Android Questions' started by Kiran Raotole, Sep 7, 2018.

  1. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    I have string 725517.5
    I want its to show as 725517.50
     
  2. prem kumar

    prem kumar New Member Licensed User

  3. Erel

    Erel Administrator Staff Member Licensed User

  4. Kiran Raotole

    Kiran Raotole Active Member Licensed User

  5. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible with NumberFormat. You will need to format it yourself.
     
  6. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Any example. How to do this?
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Sub FormatNumber (i As Int) As String
       
    Dim n As String = NumberFormat2(i, 000False)
       
    Dim sb As StringBuilder
       sb.Initialize
       
    Dim NextGroup As Int = 3
       
    For i = 0 To n.Length - 1
           
    If NextGroup = 0 Then
               sb.Insert(
    0",")
               NextGroup = 
    2
           
    End If
           sb.Insert(
    0, n.CharAt(n.Length - 1 - i))
           NextGroup = NextGroup - 
    1
       
    Next
       
    Return sb.ToString
    End Sub
     
    Kiran Raotole likes this.
  8. Semen Matusovskiy

    Semen Matusovskiy Well-Known Member Licensed User

  9. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Thanks.
     
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