Website Design United States, Website Design California, Website Designing United States, Website Designing California

Additional Boolean Functions - Visual Basic 6

Most other languages have these functions... VB does not. So here they are!

'Special thanks to Brian Morrison for submitting this code sample.

Option Explicit

Public Function Exor(x As Boolean, y As Boolean) As Boolean
'Truth table
' x y | Exor
'-------------------
' T T | T
' T F | F
' F T | F
' F F | T

Exor = Not (x Xor y)
End Function

Public Function Implication(x As Boolean, y As Boolean) As Boolean
'Truth table
' x y | Implication
'-------------------
' T T | T
' T F | F
' F T | F
' F F | T

If x Then
Implication = y
Else
Implication = Not y
End If
End Function

Public Function Inhibition(x As Boolean, y As Boolean) As Boolean
'Truth table
' x y | Inhibition
'-------------------
' T T | F
' T F | T
' F T | F
' F F | F

If x And Not y Then
Inhibition = True
Else
Inhibition = False
End If
End Function

Public Function Nand(x As Boolean, y As Boolean) As Boolean
'Truth table
' x y | Nand
'-------------------
' T T | F
' T F | T
' F T | T
' F F | F
Nand = Not (x And y)
End Function

Public Function Nor(x As Boolean, y As Boolean) As Boolean
'Truth table
' x y | Nor
'-------------------
' T T | F
' T F | F
' F T | F
' F F | T

Nor = Not (x Or y)
End Function

 
WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com