Mega Code Archive

 
Categories / VB.Net / Data Types
 

Use CInt to convert Double to Integer

Imports System.Globalization Module Example    Public Sub Main()         Dim dbl2 As Double = 99999.997         Try            Dim number2 As Integer = CInt(dbl2)            Console.WriteLine(number2)         Catch e As OverflowException            Console.WriteLine("{0} is out of range of an Int32.", dbl2)         End Try    End Sub End Module