sintassi e uso di procedure con visual basic

usa procedure e funzioni con dati da programma e da tastiera

 

 

Private Sub funzione1_Click()
Dim a As Integer
Dim b As Integer
a = 5
b = 6
ListBox1.AddItem (sommati(a, b))
funzione2.SetFocus
End Sub

Private Sub funzione2_Click()
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
ListBox1.AddItem (sommato(a, b))
cancellare.SetFocus
End Sub
Private Sub procedura1_Click()
Call sommare(1, 2, 3)
ListBox1.AddItem ("-------------")
procedura2.SetFocus
End Sub
Public Sub sommare(a As Integer, b As Integer, c As Integer)
Dim somma As Integer
somma = a + b + c
ListBox1.AddItem ("somma = " & somma)
End Sub
Private Sub procedura2_Click()
Dim x As Integer
Dim y As Integer
x = TextBox1.Text
y = TextBox2.Text
Call sommare1(x, y)
funzione1.SetFocus
End Sub
Public Sub sommare1(a As Integer, b As Integer)
Dim somma As Integer
somma = a + b
ListBox1.AddItem ("somma = " & somma)
ListBox1.AddItem ("------------")
End Sub
Private Sub cancellare_Click()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.SetFocus
End Sub
Public Function sommati(a As Integer, b As Integer)
Dim somma As Integer
somma = a + b
sommati = somma
End Function
Public Function sommato(a As Integer, b As Integer)
Dim somma As Integer
somma = a + b
sommato = somma
End Function
Private Sub UserForm_Click()
End Sub