×

VB.Net Programs

VB.Net program to demonstrate the CLng() function

By Nidhi Last Updated : November 11, 2024

CLng() function in VB.Net

The CLng() function is used to convert different data types value into the long integer type.

Syntax

CLng(val)

Parameter(s)

  • val: It may be a variable of different data types.

Return Value

The CLng() function will return a converted long integer number.

VB.Net code to demonstrate the example of CLng() function

The source code to demonstrate the CLng() function is given below. The given program is compiled and executed successfully.

'VB.Net program to demonstrate the CLng() function.

Module Module1

    Sub Main()
        Dim num As Long = 0

        Dim n1 As Single = 10.25
        Dim n2 As Integer = 12
        Dim n3 As Double = 25.35
        Dim n4 As String = "122"

        num = CLng(n1)
        Console.WriteLine("Long Integer Number: {0}", num)

        num = CLng(n2)
        Console.WriteLine("Long Integer Number: {0}", num)

        num = CLng(n3)
        Console.WriteLine("Long Integer Number: {0}", num)

        num = CLng(n4)
        Console.WriteLine("Long Integer Number: {0}", num)
    End Sub
    
End Module

Output:

Long Integer Number: 10
Long Integer Number: 12
Long Integer Number: 25
Long Integer Number: 122
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains a Main() method. In the Main() method, we created five variables num, n1, n2, n3, and n4 that are initialized with 0, 10.25, 12, 25.35, and "122".

num = CLng(n1)
Console.WriteLine("Long Integer Number: {0}", num)

num = CLng(n2)
Console.WriteLine("Long Integer Number: {0}", num)

num = CLng(n3)
Console.WriteLine("Long Integer Number: {0}", num)

num = CLng(n4)
Console.WriteLine("Long Integer Number: {0}", num)

In the above code, we converted the value of the specified variable into a long integer number and printed them on the console screen.

VB.Net Basic Programs »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.