seleziona5

chiamata di funzioni mediante selezione con Select Case
dati assegnati da codice o da tastiera
vario modo di visualizzare i risultati

Private Sub CommandButton1_Click()
Rem uso di funzioni e chiamata mediante Select Case
Const linea = "--------"
Dim a As Integer
Dim b As Integer
Dim x As Integer
Dim y As Integer
Dim k As Integer
Dim funzione1, funzione2 As Integer
a = Val(TextBox1)
b = Val(TextBox2)

funzione1 = sommare(a, b)
x = 30
y = 6

funzione2 = sottrarre(a, b)
k = TextBox3.Text
Select Case k

Case 1
funzione1 = sommare(a, b)
ListBox1.AddItem ("sommare a+b = " & funzione1)
ListBox1.AddItem (linea)
Case 2
ListBox1.AddItem ("sottrarre a-b= " & funzione2)
ListBox1.AddItem (linea)
Case 3
ListBox1.AddItem ("moltiplicare a*b =" & moltiplicare(a, b))
ListBox1.AddItem (linea)
Case 4
ListBox1.AddItem ("dividere x/y 30/6 = " & dividere(x, y))
ListBox1.AddItem (linea)
End Select
End Sub


Public Function sommare(a As Integer, b As Integer)
Dim somma As Integer
somma = a + b
sommare = somma
End Function

Public Function sottrarre(a As Integer, b As Integer)
Dim differenza As Integer
differenza = a - b
sottrarre = differenza
End Function

Public Function moltiplicare(a As Integer, b As Integer)
Dim prodotto As Integer
prodotto = a * b
moltiplicare = prodotto
End Function

Public Function dividere(a As Integer, b As Integer)
Dim quoziente As Double
quoziente = a / b
dividere = quoziente
End Function

Private Sub CommandButton2_Click()
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
End Sub

Private Sub CommandButton3_Click()
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
ListBox1.Clear
End Sub

vedi seleziona5.ppt