How to count of digits after the comma of a double number in VB.NET

1 Answer

0 votes
Imports System

Public Class Program
    Public Shared Function count_digits_after_comma(ByVal d As Double) As Integer
        Dim dstr As String = d.ToString()
		
        Return dstr.Length - dstr.IndexOf(".") - 1
    End Function

    Public Shared Sub Main()
        Dim d As Double = 9812347.9085
		
        Console.Write(count_digits_after_comma(d))
    End Sub
End Class




' run:
'
' 4
'

 



answered Mar 3, 2024 by avibootz
edited Mar 3, 2024 by avibootz

Related questions

1 answer 100 views
1 answer 115 views
1 answer 123 views
1 answer 87 views
2 answers 157 views
...