ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to demonstrate the CBool() function

Here, we are going to demonstrate the CBool() function in VB.Net.
Submitted by Nidhi, on December 06, 2020

The CBool() function is used to convert different data types value into the integer type.

Syntax:

CBool(val)

Parameters:

  • val: It is a given integer value.

Return Value:

The CBool() function will return a converted boolean value.

Program/Source Code:

The source code to demonstrate the CBool() function is given below. The given program is compiled and executed successfully.

'VB.Net program to demonstrate the CBool() function.

Module Module1

    Sub Main()
        Dim result As Boolean = False

        Dim n1 As Integer = 10
        Dim n2 As Integer = 0
        Dim n3 As Integer = -1
        
        result = CBool(n1)
        Console.WriteLine("Boolean value: {0}", result)

        result = CBool(n2)
        Console.WriteLine("Boolean value: {0}", result)

        result = CBool(n3)
        Console.WriteLine("Boolean value: {0}", result)
    End Sub
    
End Module

Output:

Boolean value: True
Boolean value: False
Boolean value: True
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 four variables result, n1, n2, and n3 that are initialized with False, 10, 0, and -10.

result = CBool(n1)
Console.WriteLine("Boolean value: {0}", result)

result = CBool(n2)
Console.WriteLine("Boolean value: {0}", result)

result = CBool(n3)
Console.WriteLine("Boolean value: {0}", result)

In the above code, we converted the value of the specified variable into boolean value, here non-zero value is converted into True and zero converted into False and then we printed them on the console screen.

VB.Net Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.