Home »
VB.Net »
VB.Net Programs
VB.Net program to demonstrate the CInt() function
By Nidhi Last Updated : November 11, 2024
CInt() function in VB.Net
The CInt() function is used to convert different data types value into the integer type.
Syntax
CInt(val)
Parameter(s)
- val: It may be a variable of different data types.
Return Value
The CInt() function will return a converted integer number.
VB.Net code to demonstrate the example of CInt() function
The source code to demonstrate the CInt() function is given below. The given program is compiled and executed successfully.
'VB.Net program to demonstrate the CInt() function.
Module Module1
Sub Main()
Dim num As Integer = 0
Dim n1 As Double = 10.25
Dim n2 As Single = 12.25
Dim n3 As Byte = 25
Dim n4 As String = "223"
num = CInt(n1)
Console.WriteLine("Integer Number: {0}", num)
num = CInt(n2)
Console.WriteLine("Integer Number: {0}", num)
num = CInt(n3)
Console.WriteLine("Integer Number: {0}", num)
num = CInt(n4)
Console.WriteLine("Integer Number: {0}", num)
End Sub
End Module
Output:
Integer Number: 10
Integer Number: 12
Integer Number: 25
Integer Number: 223
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 those are initialized with 0, 10.25, 12.25, 25, and "223".
num = CInt(n1)
Console.WriteLine("Integer Number: {0}", num)
num = CInt(n2)
Console.WriteLine("Integer Number: {0}", num)
num = CInt(n3)
Console.WriteLine("Integer Number: {0}", num)
num = CInt(n4)
Console.WriteLine("Integer Number: {0}", num)
Here, we converted the value of the specified variable into integer and printed them on the console screen.
VB.Net Basic Programs »