controllo con If Then Else

Rem controllo con If then Else con valori prefissati
con valori da inserire

vedi formato8.xls

Private Sub CommandButton1_Click()
Rem formato8
Rem controllo con If then Else
a = 10
b = 5
If a > b Then
Cells(1, 1) = a * b
End If
If a > b Then
Cells(2, 1) = a * b
Cells(3, 1) = a / b
Cells(4, 1) = a - b
End If
If a > b Then
Cells(5, 1) = a ^ 2
Else
Cells(6, 1) = b ^ 2
End If
End Sub

Private Sub CommandButton2_Click()
Rem controllo con If then Else
Dim a, b As Integer
a = TextBox1
b = TextBox2

If a > b Then
Cells(1, 4) = a * b
End If
If a > b Then
Cells(2, 4) = a * b
Cells(3, 4) = a / b
Cells(4, 4) = a - b
End If
If a > b Then
Cells(5, 4) = a ^ 2
Else
Cells(6, 4) = b ^ 2
End If
End Sub

Private Sub CommandButton3_Click()
Rem cancella
TextBox1 = ""
TextBox2 = ""
Cells(1, 1) = ""
Cells(2, 1) = ""
Cells(3, 1) = ""
Cells(4, 1) = ""
Cells(5, 1) = ""
Cells(6, 1) = ""
Cells(1, 4) = ""
Cells(2, 4) = ""
Cells(3, 4) = ""
Cells(4, 4) = ""
Cells(5, 4) = ""
Cells(6, 4) = ""
End Sub

indice