Home >>VB.Net Built-in Functions >VB.Net program to demonstrate the CULng() function

VB.Net program to demonstrate the CULng() function

Write a VB.Net program to demonstrate the CULng() function

The function CULng() is used to convert the value of various data types into the unsigned long integer type.

Syntax :

CULng(val)

Parameters :

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

Return Value :

The CULng() function returns the unsigned long integer number converted.

Program :

The source code for demonstrating the function CULng() is given below. The program given is compiled and successfully executed.


Module Module1
    Sub Main()
        Dim num As ULong = 0
        Dim n1 As Single = 10.25
        Dim n2 As Integer = 12
        Dim n3 As Double = 25.35
        Dim n4 As String = "122"
        num = CULng(n1)
        Console.WriteLine("Unsigned Long Integer Number: {0}", num)
        num = CULng(n2)
        Console.WriteLine("Unsigned Long Integer Number: {0}", num)
        num = CULng(n3)
        Console.WriteLine("Unsigned Long Integer Number: {0}", num)
        num = CULng(n4)
        Console.WriteLine("Unsigned Long Integer Number: {0}", num)
    End Sub
End Module
	
Output:
Unsigned Long Integer Number: 10
Unsigned Long Integer Number: 12
Unsigned Long Integer Number: 25
Unsigned Long Integer Number: 122

Explanation:

We created a Module1 module in the above program, which contains the Main() method. Five variables num, n1, n2, n3, and n4 have been created in the Main() method and are initialized with 0, 10.25, 12, 25.35, and 122.

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

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

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

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

In the above code, the value of the specified variable has been converted to a unsigned long integer number and printed on the console screen.


No Sidebar ads