Casting Integer To Long, Single and Double using VB.NET

Convert Integer to Long using Convert.ToInt64 (), Convert Integer to Single using Convert.ToSingle () and Convert Integer to Double using Convert.ToDouble ().
  • 5280
Download Files:

In this article, I am going to use few method that will help you to convert Integer data type to another data type like Long, Single, Double.
After using below code you can easily convert integer value to some other type. In below code first convert.Toint32 method convert user input value to integer because take user input value in string format that's the reason i need to convert string to integer. In second code, I convert Integer to Long data type using Convert.ToInt64 (Integer value). Third code, convert Integer to Single data type using Convert.ToSingle (Integer value). Fourth code, convert Integer to Double data type using Convert.ToDouble (Integer value).

integer-float.gif      integer-double.gif


Module Module1
    Sub Main()
        Console.WriteLine(" Eneter any integer" & vbLf)
        Dim str As String = Console.ReadLine()

        Dim iint As Integer = Convert.ToInt32(str)
        Console.WriteLine(vbLf & "User value convert string to integer = {0}", iint & vbLf)
        Dim iLong As Long = Convert.ToInt64(iint)
        Console.WriteLine("Convert integer to long = {0}", iLong & vbLf)
        Dim ifloat As Single = Convert.ToSingle(iint)
        Console.WriteLine("Convert integr to float = {0}", ifloat & vbLf)
        Dim idouble As Double = Convert.ToDouble(iint)
"Convert integer to double = {0}", idouble & vbLf)
    End Sub
End Module




More Articles

© 2013 dotNetheaven. All rights reserved.