How to get the first two digits after the decimal point of a float number in VB.NET

1 Answer

0 votes
Imports System
  
Public Class Test
    Public Shared Sub Main()
        Dim f As Single = 7312.891
        Dim s As String = f.ToString()
         
        Console.Write(s.Substring(s.IndexOf(".") + 1, 2))
    End Sub
End Class
  
  
  
  
' run:
'
' 89
'

 



answered Aug 30, 2019 by avibootz
...