Results 1 to 3 of 3

Thread: Problem with final result

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Problem with final result

    Hi to all:

    THis code extract a value from a table to a var...

    Code:
    Dim var_IES_fornecedores as double = 0
    For Each dRow In ds.Tables("Tabelavalor").Rows
    If dRow("numeroconta").Equals("221") Then
                    If dRow("acumuladosdebito").Equals("0,00") Then
                    Else
                        Var_IES_Fornecedores -= FormatNumber(dRow("acumuladosdebito"), 2) 
                    End If
                End If
                If dRow("numeroconta").Equals("221") Then
                    If dRow("acumuladoscredito").Equals("0,00") Then
                    Else
                        Var_IES_Fornecedores += FormatNumber(dRow("acumuladoscredito"), 2)
                    End If
                End If
      Next
    the Var_IES_Fornecedores return a value = 174526.852222225
    This is the problem...the numbers after the period should be just 2 and not a lot of numbers...
    everythin wrong with the code?


    Thanks

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Problem with final result

    Once you get that Double value, you can do whatever you want with it. You can use the Math.Round function to round it to 2 decimal places if that is what you desire. If all you want to do is display that value to 2 decimal places, you can use the ToString method:
    Code:
    Dim value = 151592.124124124R
    Dim text = value.ToString("0.00")
    
    Console.WriteLine(text)
    Output:
    Code:
    151592.12

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: Problem with final result

    hi:

    yes works with .tostring

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width