funzioni di controllo con IF e visual basic
Private Sub CommandButton1_Click() Dim a As Integer Dim b As Integer a = TextBox1.Text b = TextBox2.Text If verifica(a, b) Then Call prodotto(a, b) Else Call somma(a, b) End If End Sub
Public Function verifica(a As Integer, b As Integer) If (a > 10 And b > 100) Then verifica = True Else If (a < 10 And b < 100) Then verifica = True Else If (a < 10 And b > 100) Or (a > 10 And b < 100) Then verifica = False End If End If End If End Function
Public Sub prodotto(a As Integer, b As Integer) Label1.Caption = a * b End Sub
Public Sub somma(a As Integer, b As Integer) Label1.Caption = a + b End Sub
Private Sub UserForm_Click()
End Sub