Hi,
Thank you for your reply. You are rigth... I must to be more clear.
I will try to do it with an example:
Dim valore as long = 123,1234567890
And I would like to get 123,12345....
Must I use FormatNumber(valore, 5)?
Is it correct or there are other ways?
Thank you!
Cheers BlackSun
Try this
Dim valore As Decimal
Dim npos As Integer
Dim c As String
' with more than 5 places after the decimal point
valore = 123.123456789
npos = InStr(valore.ToString("##0.0000000000").Trim(), ".")
c = Strings.Left(valore.ToString("##0.0000000000").Trim(),
npos - 1) & "." & _
Strings.Left(valore.ToString("##0.0000000000").Trim
().Substring(npos), 5)
Console.WriteLine("more than 5 decimal places {0}", c)
' with less than 5 places after the decimal point
valore = 123.123
npos = InStr(valore.ToString("##0.0000000000").Trim(), ".")
c = Strings.Left(valore.ToString("##0.0000000000").Trim(),
npos - 1) & "." & _
Strings.Left(valore.ToString("##0.0000000000").Trim
().Substring(npos), 5)
Console.WriteLine("less than 5 decimal places {0}", c)
' exactly 5 places after decimal point
valore = 123.12345
npos = InStr(valore.ToString("##0.0000000000").Trim(), ".")
c = Strings.Left(valore.ToString("##0.0000000000").Trim(),
npos - 1) & "." & _
Strings.Left(valore.ToString("##0.0000000000").Trim
().Substring(npos), 5)
Console.WriteLine("exactly 5 decimal places {0}", c)
' no decimals
valore = 123
npos = InStr(valore.ToString("##0.0000000000").Trim(), ".")
c = Strings.Left(valore.ToString("##0.0000000000").Trim(),
npos - 1) & "." & _
Strings.Left(valore.ToString("##0.0000000000").Trim
().Substring(npos), 5)
Console.WriteLine("no decimals {0}", c)
HTH,
Diego