CBool Function in VB.NET

How to convert integer value to Boolean value in VB.Net?

Explanation

CBool Function - Convert Integer Value to Boolean

CBool Function in Visual Basic.net 2008 is used to convert an integer value to Boolean datatype.
Syntax:

CBool(expression)
Example:

Module Module1
Sub Main()
Dim a As String = "welcome"
Dim b As String = "WELCOME"
Console.WriteLine("Boolean value of a=b is:: " & CBool(a = b))
Console.ReadLine()
End Sub
End Module
Result:

Boolean value of a=b is::True

In the above example, two strings are compared in an expression and CBool() is used to convert an integer value to boolean datatype.

Visual Basic Tutorial


Ask Questions

Ask Question