ritorna con variabili.html descrizione gestione variabili con VBA
esci con
vbasintassi1.htm


numeriche6.ppt
operazioni aritmetiche con variabili numeriche (
valori interi da tastiera)
e visualizzazione risultati con: label.caption


Private Sub CommandButton1_Click()
Rem dimensionamento
Dim a, b As Byte
Dim c, d, prodotto1, prodotto2, differenza1, differenza2 As Integer
Dim e, f, prodotto3, differenza3 As Long
Rem assegnazione valore
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
e = TextBox5.Text
f = TextBox6.Text
Rem assegno operazione
prodotto1 = a * b
differenza1 = a - b
prodotto2 = c * d
differenza2 = c - d
prodotto3 = e * f
differenza3 = e - f
Rem stampo risultati
Label4.Caption = ("prodotto1 = " & prodotto1)
Label5.Caption = ("differenza1 = " & differenza1)
Label6.Caption = ("prodotto2 = " & prodotto2)
Label7.Caption = ("differenza22 = " & differenza2)
Label8.Caption = ("prodotto3 = " & prodotto3)
Label9.Caption = ("differenza33 = " & differenza3)
End Sub

Private Sub CommandButton2_Click()
Label1.Visible = True
End Sub

Private Sub CommandButton3_Click()
Label1.Visible = False
End Sub


Private Sub UserForm_Click()

End Sub


numeriche7.ppt

simile a numeriche6.ppt (valori anche decimali)


Private Sub CommandButton1_Click()
Rem dimensionamento
Dim a, b, prodotto1, somma1 As Single
Dim c, d, podotto2, somma2 As Double
Dim e, f, prodotto3, somma3 As Currency
Rem assegnazione valore
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
e = TextBox5.Text
f = TextBox6.Text
Rem assegno operazione
prodotto1 = a * b
somma1 = a + b
prodotto2 = c * d
somma2 = c + d
prodotto3 = e * f
somma3 = e + f
Rem stampo risultati
Label4.Caption = ("prodotto1 = " & prodotto1)
Label5.Caption = ("somma1 = " & somma1)
Label6.Caption = ("prodotto2 = " & prodotto2)
Label7.Caption = ("somma22 = " & somma2)
Label8.Caption = ("prodotto3 = " & prodotto3)
Label9.Caption = ("somma3 = " & somma3)
End Sub

Private Sub CommandButton2_Click()
Label1.Visible = True
End Sub

Private Sub CommandButton3_Click()
Label1.Visible = False
End Sub



Private Sub UserForm_Click()

End Sub


numeriche8.ppt
operatore somma (+) talvolta puņ considerare come stringhe valori numerici
inseriti da tastiera a,b ( 8+5 rende 85 <>13) ; (15+9 rende 159 <> 24)
la funzione Val(a)+Val(b) rende 15 ; Val(e)+Val(f) rende 24


Private Sub CommandButton1_Click()
Rem dimensionamento
Dim a, b, somma1 As Byte
Dim c, d, prodotto1, prodotto2, somma2 As Integer
Dim e, f, prodotto3, somma3 As Long
Rem assegnazione valore
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
e = TextBox5.Text
f = TextBox6.Text
Rem assegno operazione
prodotto1 = a * b
Rem a, b considerati stringhe con operatore +
somma1 = a + b
prodotto2 = c * d
Rem c, d considerati stringhe con operatore +
somma2 = c + d
prodotto3 = e * f
Rem val(e)+ val(f) somma valori numerici di e,f
somma3 = Val(e) + Val(f)
Rem stampo risultati
Label4.Caption = ("prodotto1 = " & prodotto1)
Label5.Caption = ("somma1 = " & somma1)
Label6.Caption = ("prodotto2 = " & prodotto2)
Label7.Caption = ("somma2 = " & somma2)
Label8.Caption = ("prodotto3 = " & prodotto3)
Label9.Caption = ("somma3 = " & somma3)
End Sub

Private Sub CommandButton2_Click()
Label1.Visible = True
End Sub

Private Sub CommandButton3_Click()
Label1.Visible = False
End Sub


Private Sub UserForm_Click()

End Sub

 


numeriche9.ppt
inserimento da tastiera di Integer, Long, Double in listbox


Private Sub CommandButton1_Click()
Rem dimensionamento
Dim a, b, prodotto1, differenza1 As Integer
Dim c, d, prodotto2, differenza2 As Long
Dim e, f, prodotto3, differenza3 As Double

Rem assegnazione valore
a = TextBox1
b = TextBox2
c = TextBox3
d = TextBox4
e = TextBox5
f = TextBox6
Rem assegno operazione
prodotto1 = a * b
differenza1 = a - b
prodotto2 = c * d
differenza2 = c - d
prodotto3 = e * f
differenza3 = e - f
Rem stampo risultati
ListBox1.AddItem ("prodotto1 = " & prodotto1)
ListBox1.AddItem ("differenza1 = " & differenza1)
ListBox1.AddItem ("--------------------")
ListBox1.AddItem ("prodotto2 = " & prodotto2)
ListBox1.AddItem ("differenza2 = " & differenza2)
ListBox1.AddItem ("--------------------")
ListBox1.AddItem ("prodotto3 = " & prodotto3)
ListBox1.AddItem ("differenza3 = " & differenza3)
ListBox1.AddItem ("--------------------")
End Sub

Private Sub CommandButton2_Click()
Label1.Visible = True
End Sub

Private Sub CommandButton3_Click()
Label1.Visible = False
End Sub



Private Sub UserForm_Click()

End Sub


inserimento da tastiera di Integer, Long, Double in Combobox

numeriche10.ppt