funzioni di controllo logiche OR XOR NOT con visual basic

controlla con NOT

controlla con XOR

controlla con OR

 

 

Private Sub Controllanot_Click()
'(prodotto se TRUE somma se FALSE)
Dim x As Integer
Dim y As Integer
TextBox1.SetFocus
x = TextBox1.Text
y = TextBox2.Text
If verifica(x, y) Then    '(esegue prodotto se true)
Label1.Caption = x * y
Else
Label1.Caption = x + y  '(esegue somma se false)
End If
End Sub
Private Function verifica(x As Integer, y As Integer) As Integer
'(TRUE se x>100 e x non maggiore di 200)
If (x > 100) And Not (y > 200) Then
verifica = True
Else
verifica = False
End If
End Function
Private Sub ControllaXor_Click()
Dim x As Integer
Dim y As Integer
TextBox1.SetFocus
x = TextBox1.Text
y = TextBox2.Text
If verificare(x, y) Then
Label1.Caption = x * y
Else
Label1.Caption = x + y
End If
End Sub
Private Function verificare(x As Integer, y As Integer) As Integer
'(TRUE se x>100 e x<200)
If (x > 100) Xor (y < 200) Then
verificare = False
Else
If (x < 100) Xor (y > 200) Then
verificare = False
Else
If (x > 100) Xor (y > 200) Then
verificare = True
End If
End If
End If
End Function
Private Sub controllaOR_Click()
'(prodotto se TRUE somma se FALSE)
Dim x As Integer
Dim y As Integer
TextBox1.SetFocus
x = TextBox1.Text
y = TextBox2.Text
If verifi(x, y) Then
Label1.Caption = x * y
Else
Label1.Caption = x + y
End If
End Sub
Private Function verifi(x As Integer, y As Integer) As Integer
'(FALSE se x<100 o y >200 )
If (x < 100) Or (y > 200) Then
verifi = False
Else
verifi = True
End If
End Function