CLng Function in VB.NET

How to convert a string to long data type in VB.Net?

Explanation

CLng Function - Convert String to Long

CLng Function in Visual Basic.net 2008 is used convert a String in Long Datatype. This function uses the locale settings to determine how to convert datatypes.
Syntax:

CLng(expression)
Example:

Module Module1
Sub Main()
Dim x As Double = 21.43
Dim y As Double = 21.51
Console.WriteLine('Double value 21.43 converted to Long is:: ' & CLng(x))
Console.WriteLine('Double value 21.51 converted to Long is:: ' & CLng(y))
Console.ReadLine()
End Sub
End Module
Result:

Double value 21.43 converted to Long is:: 21
Double value 21.51 converted to Long is:: 22

In the above example, an double integer expression is converted to Long datatype.

Visual Basic Tutorial


Ask Questions

Ask Question