chiamata di procedura
chiamata di procedura con passaggio valori a , b

vedi formato13.xls

Private Sub CommandButton1_Click()
Dim b As Integer
Dim a As Integer
a = TextBox1
If a > 100 Then
a = 100
MsgBox ("massimo per a = 100")
End If
b = TextBox2
If b > 30 Then
b = 30
MsgBox ("massino per b = 30")
End If
Call calcolare(a, b) ' chiamata di procedura con passaggio valori a , b '
Call eseguire(a, b) ' chiamata di procedura con passaggio valori a,b'
End Sub

Public Sub calcolare(a As Integer, b As Integer)
Dim somma, prodotto As Integer
somma = a + b
prodotto = a * b
Cells(1, 1) = somma
Cells(1, 2) = prodotto
End Sub

Public Sub eseguire(a As Integer, b As Integer)
Dim quadrato, cubo As Integer
quadrato = a * a
cubo = b * b * b
ListBox1.AddItem ("a*a = " & quadrato)
ListBox1.AddItem ("b*b*b = " & cubo)
End Sub

Private Sub commandbutton2_Click() ' cancellare tutto'
TextBox1 = ""
TextBox2 = ""
Cells(1, 1) = ""
Cells(1, 2) = ""
ListBox1.Clear
End Sub


indice