descrizione gestione variabili
con VBA
ritorna con variabili.html esci con vbasintassi1.htm
numeriche17.ppt
uso di Public per rendere visibili variabili in tutto il programma
Public nx, n As Integer
Public linea As String
Rem con Public si dichiarano le variabile nx,n
Rem che saranno note in tutte le subroutine che le richiamano
Private Sub CommandButton2_Click()
Dim sottrazione, somma, prodotto As Integer
nx = 100
linea = "-----------------------"
n = Val(TextBox1)
sottrazione = nx - n
somma = nx + n
prodotto = nx * n
If n < nx Then
ListBox1.AddItem ("eseguo sottrazione :" &
sottrazione)
ListBox1.AddItem (linea)
End If
If n = nx Then
ListBox1.AddItem ("eseguo prodotto :" & prodotto)
ListBox1.AddItem (linea)
End If
If n > nx Then
ListBox1.AddItem ("eseguo somma :" & somma)
ListBox1.AddItem (linea)
End If
End Sub
Private Sub CommandButton3_Click()
TextBox1 = ""
End Sub
Private Sub UserForm_Click()
End Sub
indovinare numero tra estremi forniti
Public nx, k, n As
Integer
Public linea As String
Rem con Public si dichiarano le variabile nx, linea
Rem che saranno note in tutte le subroutine che le richiamano
Private Sub commandbutton1_click()
nx = 8
k = 0
linea = "-----------------------"
End Sub
Private Sub CommandButton2_Click()
n = Val(TextBox1.Text)
If n < nx Then
ListBox1.AddItem ("minore :")
ListBox1.AddItem (linea)
End If
If n = nx Then
ListBox1.AddItem ("uguale :")
ListBox1.AddItem (linea)
End If
If n > nx Then
ListBox1.AddItem ("maggiore :")
ListBox1.AddItem (linea)
End If
ListBox1.AddItem ("tentativo n.= " & k)
k = k + 1
End Sub
Private Sub CommandButton3_Click()
TextBox1 = ""
End Sub
Private Sub CommandButton4_Click()
Label1.Visible = True
End Sub
Private Sub CommandButton5_Click()
Label1.Visible = False
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub UserForm_Click()
End Sub
numeriche19.ppt
simile a numeriche18.ppt (pensato
da tastiera textbox2)
Public nx, k, n, x, y As Integer
Public linea As String
Rem con Public si dichiarano le variabile nx, linea
Rem che saranno note in tutte le subroutine che le richiamano
Private Sub commandbutton1_click()
nx = Val(TextBox2.Text)
k = 0
linea = "-----------------------"
x = TextBox3
y = TextBox4
End Sub
Private Sub CommandButton2_Click()
n = Val(TextBox1.Text)
If n < nx Then
ListBox1.AddItem ("minore :")
ListBox1.AddItem (linea)
End If
If n = nx Then
ListBox1.AddItem ("uguale :")
ListBox1.AddItem (linea)
End If
If n > nx Then
ListBox1.AddItem ("maggiore :")
ListBox1.AddItem (linea)
End If
ListBox1.AddItem ("tentativo n.= " & k)
k = k + 1
End Sub
Private Sub CommandButton3_Click()
TextBox1 = ""
End Sub
Private Sub CommandButton4_Click()
Label5.Visible = True
End Sub
Private Sub CommandButton5_Click()
Label5.Visible = False
End Sub
Private Sub CommandButton6_Click()
TextBox2.Visible = False
End Sub
Private Sub CommandButton7_Click()
TextBox2.Visible = True
End Sub
Private Sub UserForm_Click()
End Sub
numeriche20.ppt
simile a numeriche19.ppt (indovina carattere)
pochi
cambiamenti
Public nx, n, x, y As
String
Public k As Integer
Public linea As String
Rem con Public si dichiarano le variabile nx, linea
Rem che saranno note in tutte le subroutine che le richiamano
Private Sub commandbutton1_click()
nx = (TextBox2.Text)
k = 0
linea = "-----------------------"
x = TextBox3
y = TextBox4
End Sub
Private Sub CommandButton2_Click()
n = TextBox1.Text
If n < nx Then
ListBox1.AddItem ("precede :")
ListBox1.AddItem (linea)
End If
If n = nx Then
ListBox1.AddItem ("uguale :")
ListBox1.AddItem (linea)
End If
If n > nx Then
ListBox1.AddItem ("segue :")
ListBox1.AddItem (linea)
End If
ListBox1.AddItem ("tentativo n.= " & k)
k = k + 1
End Sub
Private Sub CommandButton3_Click()
TextBox1 = ""
End Sub
Private Sub CommandButton4_Click()
Label5.Visible = True
End Sub
Private Sub CommandButton5_Click()
Label5.Visible = False
End Sub
Private Sub CommandButton6_Click()
TextBox2.Visible = False
End Sub
Private Sub CommandButton7_Click()
TextBox2.Visible = True
End Sub
Private Sub Label3_Click()
End Sub
Private Sub Label5_Click()
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub UserForm_Click()
End Sub