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


numeriche1.ppt
operazioni aritmetiche con variabili numeriche (valori interi assegnati)
e visualizzazione risultati con: textbox.text, listbox.additem, label.caption


Private Sub CommandButton1_Click()
Rem dimensionamento
Dim a, b, prodotto1, somma1 As Byte
Dim c, d, prodotto2, s9mma2 As Integer
Dim e, f, prodotto3, somma2 As Long
Rem assegnazione valore
a = 10
b = 20
c = 100
d = 10
e = 200
f = 100
Rem assegno operazione
prodotto1 = a * b
somma1 = a + b
prodotto2 = c * d
somma2 = c + d
prodotto3 = e * f
somma3 = e + f
Rem stampo risultati
TextBox1.Text = ("prodotto1 = " & prodotto1)
TextBox2.Text = ("somma1 = " & somma1)
TextBox3.Text = ("prodotto2 = " & prodotto2)
TextBox4.Text = ("somma2 = " & somma2)
TextBox5.Text = ("prodotto3 = " & prodotto3)
TextBox6.Text = ("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


numeriche2.ppt

variante di numeriche1.ppt (vedi codice semplificato)



numeriche3.ppt
simile a numeriche1.ppt con altre variabili(con decimali)

 


Private Sub CommandButton1_Click()
Rem dimensionamento
Dim a, b, prodotto1, somma1 As Single
Dim c, d, prodotto2, s9mma2 As Double
Dim e, f, prodotto3, somma2 As Currency
Rem assegnazione valore
a = 5000
b = 113
c = 5000000
d = 113
e = 6000000
f = 113
Rem assegno operazione
quoziente1 = a / b
somma1 = a + b
quoziente2 = c / d
somma2 = c + d
quoziente3 = e / f
somma3 = e + f
Rem stampo risultati
TextBox1.Text = ("quoziente1 = " & quoziente1)
TextBox2.Text = ("somma1 = " & somma1)
TextBox3.Text = ("quoziente2 = " & quoziente2)
TextBox4.Text = ("somma2 = " & somma2)
TextBox5.Text = ("quoziente3 = " & quoziente3)
TextBox6.Text = ("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


numeriche4.ppt
variante di numeriche1.ppt (vedi codice con ListBox)


Private Sub CommandButton1_Click()
Rem dimensionamento
Dim a, b, prodotto1, somma1 As Byte
Dim c, d, prodotto2, s9mma2 As Integer
Dim e, f, prodotto3, somma2 As Long
Rem assegnazione valore
a = 10
b = 20
c = 100
d = 10
e = 200
f = 100
Rem assegno operazione
prodotto1 = a * b
somma1 = a + b
prodotto2 = c * d
somma2 = c + d
prodotto3 = e * f
somma3 = e + f
Rem stampo risultati
ListBox1.AddItem ("prodotto1 = " & prodotto1)
ListBox1.AddItem ("somma1 = " & somma1)
ListBox1.AddItem ("--------------------")
ListBox1.AddItem ("prodotto2 = " & prodotto2)
ListBox1.AddItem ("somma2 = " & somma2)
ListBox1.AddItem ("--------------------")
ListBox1.AddItem ("prodotto3 = " & prodotto3)
ListBox1.AddItem ("somma3 = " & somma3)
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


numeriche55.ppt

variante di numeriche4.ppt (vedi codice con ComboBox)

 


numeriche5.ppt

variante di numeriche1.ppt (vedi codice con Label.caption)


Private Sub CommandButton1_Click()
Rem dimensionamento
Dim a, b, prodotto1, somma1 As Byte
Dim c, d, prodotto2, s9mma2 As Integer
Dim e, f, prodotto3, somma2 As Long
Rem assegnazione valore
a = 10
b = 20
c = 100
d = 10
e = 200
f = 100
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 = ("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 Label9_Click()

End Sub

Private Sub UserForm_Click()

End Sub