ARTICLE

Convert Integer To Long, Single and Double in vb.net

Posted by Sapna Articles | Visual Basic Language July 08, 2011
Convert Integer to Long using Convert.ToInt64 (), Convert Integer to Single using Convert.ToSingle () and Convert Integer to Double using Convert.ToDouble ().
Download Files:
 
Reader Level:

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 vb.net 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).

Convert Integer To FLoat      Convert Integer To Double

Code :

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)

        Console.WriteLine("Convert integer to double = {0}", idouble & vbLf)

        Console.ReadLine()

    End Sub

End Module

Output 

output.gif

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor