procedura1
esempio di VBA
con powerpoint per confrontare con VBA su excel
esci con vbavarie.htm
procedura1.ppt chiamata di procedure
Private Sub provax(a As Integer, b As Integer,
c As Integer)
Dim totale As Integer
If (a > 0) And (b > 0) And (c > 0) Then
totale = a + b + c
Lista.AddItem ("somma=" & totale)
Else
Lista.AddItem ("almeno un numero è minore o = 0 = ")
& a + b + c
End If
End Sub
Private Sub CommandButton1_Click()
Call provax(1, 2, 3)
MsgBox ("clicca")
Call provax(0, 1, 2)
MsgBox ("clicca")
Call provax(1, 2, -6)
End Sub
Private Sub provay(a As Integer, b As Integer, c As Integer)
Dim totale As Integer
If (a > 0) And (b > 0) And (c > 0) Then
totale = a * b * c
Lista.AddItem ("prodotto= " & totale)
Else
Lista.AddItem ("almeno un numero minore o uguale di
0=") & a * b * c
End If
End Sub
Private Sub CommandButton2_Click()
Call provay(1, 2, 10)
MsgBox ("clicca")
Call provay(0, 2, 8)
End Sub
Private Sub provaz(a As Integer, b As Integer, c As Integer)
Dim totale As Integer
If ((a > 0) And (b > 0)) Or (c < 0) Then
totale = a + b + c
Lista.AddItem ("somma= " & totale)
Else
Lista.AddItem ("almeno un numero deve essere minore di
0")
End If
End Sub
Private Sub CommandButton3_Click()
Call provaz(0, -2, -4)
MsgBox ("clicca")
Call provaz(1, 4, 2)
End Sub
Private Sub CommandButton4_Click()
Lista.Clear
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub provastringa(a1 As
String, a2 As String)
Rem uso di carattere & come operatore di somma
Rem o separatore
Dim somma, somma1 As String
Dim virgola As String
somma = a1 & a2
somma1 = a1 + a2
virgola = a1 & " , " & a2
ListBox1.AddItem ("a1 & a2 " & somma)
ListBox1.AddItem ("a1 + a2 " & somma1)
MsgBox ("clicca")
ListBox1.AddItem ("-----")
ListBox1.AddItem (("a1 , a2 ") & virgola)
End Sub
Private Sub CommandButton1_Click()
Call provastringa("Rossi", "Paolo")
ListBox1.AddItem ("......")
Call provastringa("Maria", "Rosa")
End Sub
Private Sub UserForm_Click()
End Sub