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