VB.Net/Language Basics/Boolean
Версия от 16:40, 26 мая 2010; (обсуждение)
Содержание
(CBool(5) And CBool(8)) with (5 And 8)
Imports System
Imports System.Data
Imports System.Collections
public class MainClass
Shared Sub Main()
Console.WriteLine("5 And 8: " + (CBool(5) And CBool(8)).ToString)
Console.WriteLine("5 And 8: " + (5 And 8).ToString())
End Sub
End Class
Convert boolean to int value
Imports System
Imports System.Data
Imports System.Collections
public class MainClass
Shared Sub Main()
Dim A As Boolean
Dim I As Integer
A = True
I = CInt(A)
Console.WriteLine("True Value of Boolean in Integer is: " + I.ToString())
A = False
I = CInt(A)
Console.WriteLine("False Value of Boolean in Integer is: " + I.ToString())
End Sub
End Class
Convert int value to Boolean value
Imports System
Imports System.Data
Imports System.Collections
public class MainClass
Shared Sub Main()
Dim A As Boolean
Dim I As Integer
I = 5
A = CBool(I)
Console.WriteLine("Value of Boolean assigned from 5 is : " + A.ToString())
I = 0
A = CBool(I)
Console.WriteLine("Value of Boolean assigned from 0 is : " + A.ToString())
I = -1
A = CBool(I)
Console.WriteLine("Value of Boolean assigned from -1 is : " + A.ToString())
I = -5
A = CBool(I)
Console.WriteLine("Value of Boolean assigned from -5 is : " + A.ToString())
End Sub
End Class
Convert to int back and forth
Imports System
Imports System.Data
Imports System.Collections
public class MainClass
Shared Sub Main()
Dim A As Boolean
Dim I As Integer
I = 5
A = CBool(I)
Console.WriteLine("Value of Boolean assigned from 5 is : " + A.ToString())
I = CInt(A)
Console.WriteLine("And converted back to Integer: " + I.ToString())
End Sub
End Class