How to cast to Integer in VB.NET

2 Answers

0 votes
Imports System
				
Public Module Module1
	Public Sub Main()
		Console.WriteLine(CInt(3.4))
		Console.WriteLine(CInt(3.5))
		Console.WriteLine(CInt(3.6))
	End Sub
End Module



' run:
' 
' 3
' 4
' 4
'

 



answered Dec 2, 2020 by avibootz
0 votes
Imports System
				
Public Module Module1
	Public Sub Main()
		Console.WriteLine(Convert.ToInt32(3.4))
        Console.WriteLine(Convert.ToInt32(3.5))
        Console.WriteLine(Convert.ToInt32(3.6))
	End Sub
End Module



' run:
' 
' 3
' 4
' 4
'

 



answered Dec 3, 2020 by avibootz
...