funzioni logiche NOT AND OR con visual basic

 

 

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