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,845 questions

51,766 answers

573 users

How to convert a specified value to a 64-bit signed integer (Convert.ToInt64) in VB.NET

1 Answer

0 votes
Imports System

Public Class Program
    Public Shared Sub Main(ByVal args As String())
        Dim arr As Single() = {Single.MinValue, -2.18e10F, -4012.309F, -18.07F, 
			                   0F, 7.018e-16F, 981.276F, 23004.7815F, Single.MaxValue}

        For Each value As Single In arr
            Try
                Dim result As Long = Convert.ToInt64(value)
                Console.WriteLine("{0} = {1}", value, result)
            Catch __unusedOverflowException1__ As OverflowException
                Console.WriteLine("{0} is outside the range of the Int64 type", value)
            End Try
        Next
    End Sub
End Class



' run:
'
' -3.402823E+38 is outside the range of the Int64 type
' -2.18E+10 = -21799999488
' -4012.309 = -4012
' -18.07 = -18
' 0 = 0
' 7.018E-16 = 0
' 981.276 = 981
' 23004.78 = 23005
' 3.402823E+38 is outside the range of the Int64 type
' 

 



answered May 24, 2024 by avibootz
...