B Bill Norris Active Member Licensed User Longtime User Jun 5, 2012 #1 Am puzzled by Numberformat2, as follows. I am trying to use the same Numberformat2 parameters to handle displaying the value correctly, regardless of the original value. If value is an integer, I don't want to display any fractions, only the integer. If value has any fractions, I want to always display 2 places to right of decimal 32 will display 32 (not 32.00) 9.5 will display 9.50 9.75 will display 9.75 Do I need to test the value first to see if it is an integer, and then select the correct Numberformat2 parameters to use depending on if it is an integer or not?
Am puzzled by Numberformat2, as follows. I am trying to use the same Numberformat2 parameters to handle displaying the value correctly, regardless of the original value. If value is an integer, I don't want to display any fractions, only the integer. If value has any fractions, I want to always display 2 places to right of decimal 32 will display 32 (not 32.00) 9.5 will display 9.50 9.75 will display 9.75 Do I need to test the value first to see if it is an integer, and then select the correct Numberformat2 parameters to use depending on if it is an integer or not?
Erel B4X founder Staff member Licensed User Longtime User Jun 5, 2012 #2 Yes. Try this: Code: Sub FormatValue(n As Double) As String If Floor(n) = n Then Return n Return NumberFormat2(n, 0, 2, 2, False) End Sub Upvote 0
Yes. Try this: Code: Sub FormatValue(n As Double) As String If Floor(n) = n Then Return n Return NumberFormat2(n, 0, 2, 2, False) End Sub
luke2012 Well-Known Member Licensed User Longtime User Jun 5, 2013 #3 If I wish a format like this : 00,00 Which parameter I must pass to the numberformat2 ? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jun 5, 2013 #4 Please start a new thread for this question. Upvote 0