Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,888 questions

51,815 answers

573 users

How to cast (convert) double or single to int in VB.NET

4 Answers

0 votes
Imports System

Public Class Test
    Public Shared Sub Main()
        Console.WriteLine(Int(29.9))
        Console.WriteLine(Fix(29.9))
        
        Console.WriteLine(Int(-29.9))
        Console.WriteLine(Fix(-29.9))
        
        Console.WriteLine(Int(29.2))
        Console.WriteLine(Fix(29.2))
        
        Console.WriteLine(Int(-29.2))
        Console.WriteLine(Fix(-29.2))
    End Sub
End Class



' run:
' 
' 29
' 29
' -30
' -29
' 29
' 29
' -30
' -29

 



answered Apr 20, 2019 by avibootz
0 votes
Imports System

Public Class Test
    Public Shared Sub Main()
        Console.WriteLine(CInt(29.9))
        Console.WriteLine(CInt(-29.9))
        Console.WriteLine(CInt(29.2))
        Console.WriteLine(CInt(-29.2))
    End Sub
End Class



' run:
' 
' 30
' -30
' 29
' -29

 



answered Apr 20, 2019 by avibootz
0 votes
Public Class Test
    Public Shared Sub Main()
        Console.WriteLine(CInt(Int(29.9)))
        Console.WriteLine(CInt(Fix(29.9)))
        
        Console.WriteLine(CInt(Int(-29.9)))
        Console.WriteLine(CInt(Fix(-29.9)))
        
        Console.WriteLine(CInt(Int(29.2)))
        Console.WriteLine(CInt(Fix(29.2)))
        
        Console.WriteLine(CInt(Int(-29.2)))
        Console.WriteLine(CInt(Fix(-29.2)))
    End Sub
End Class



' run:
' 
' 29
' 29
' -30
' -29
' 29
' 29
' -30
' -29

 



answered Apr 20, 2019 by avibootz
0 votes
Imports System

Public Class Test
    Public Shared Sub Main()
        Console.WriteLine(CInt(Int(385.7638)))
        Console.WriteLine(CInt(Fix(385.7638)))
        
        Console.WriteLine(CInt(Int(-385.7638)))
        Console.WriteLine(CInt(Fix(-385.7638)))
        
        Console.WriteLine(Int(385.7638))
        Console.WriteLine(Fix(385.7638))
        
        Console.WriteLine(Int(-385.7638))
        Console.WriteLine(Fix(-385.7638))
    End Sub
End Class



' run:
' 
' 385
' 385
' -386
' -385
' 385
' 385
' -386
' -385

 



answered Apr 20, 2019 by avibootz

Related questions

1 answer 139 views
139 views asked Nov 15, 2021 by avibootz
1 answer 138 views
1 answer 104 views
2 answers 165 views
165 views asked Dec 2, 2020 by avibootz
1 answer 141 views
2 answers 195 views
...