calcolare4

 

Option Explicit
Public memoria As Double
Public segno As String



Private Sub applica_Click()
Rem prepara tastiera numerica
Dim n As Integer
Dim k(10) As Integer

For n = 0 To 9
k(n) = n
Next n
tasto0.Caption = k(0)
tasto1.Caption = k(1)
tasto2.Caption = k(2)
tasto3.Caption = k(3)
tasto4.Caption = k(4)
tasto5.Caption = k(5)
tasto6.Caption = k(6)
tasto7.Caption = k(7)
tasto8.Caption = k(8)
tasto9.Caption = k(9)
memoria = 0
segno = "+"
funzione.SetFocus
End Sub


Private Sub CommandButton1_Click()
valore.Text = ""
End Sub

Private Sub Calcola()
Select Case segno
Case "+"
memoria = memoria + valore.Text
Case "*"
memoria = memoria * valore.Text
Case "-"
memoria = memoria - valore.Text
Case "/"
memoria = memoria / valore.Text
End Select
valore.Text = ""
End Sub


Private Sub calcolare_Click()
Call Calcola
valore.Text = memoria
funzione.Text = memoria
memoria = 0
segno = "+"
End Sub

Private Sub cancella_Click()
valore.Text = ""
funzione.Text = ""
funzione.SetFocus
End Sub

Private Sub CommandButton6_Click()

End Sub

Private Sub Coseno_Click()
valore.Text = Cos((funzione * 3.14) / 180)
End Sub

Private Sub differenza_Click()
Call Calcola
segno = "-"
End Sub

Private Sub divisione_Click()
Call Calcola
segno = "/"
End Sub

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

Private Sub Label2_Click()

End Sub

Private Sub log10_Click()
If funzione > 0 Then
valore.Text = Log(funzione) / Log(10)
Else
MsgBox "deve essere maggiore di 0"
End If
End Sub

Private Sub lognat_Click()
If funzione > 0 Then
valore.Text = Log(funzione)
Else
MsgBox "deve essere maggiore di 0"
End If
End Sub

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

Private Sub prodotto_Click()
Call Calcola
segno = "*"
End Sub

Private Sub quadrato_Click()
valore.Text = funzione * funzione
End Sub

Private Sub radiceq_Click()
If funzione > 0 Then
valore.Text = Sqr(funzione)
Else
MsgBox "deve essere maggiore di 0"
End If
End Sub

Private Sub seno_Click()
valore.Text = Sin((funzione * 3.14) / 180)
End Sub

Private Sub somma_Click()
Call Calcola
segno = "+"
End Sub

Private Sub tangente_Click()
valore.Text = Sin((funzione * 3.14) / 180) / Cos((funzione * 3.14) / 180)
End Sub

Private Sub tasto0_Click()
valore.Text = valore.Text & 0
End Sub

Private Sub tasto1_Click()
valore.Text = valore.Text & 1
End Sub

Private Sub tasto2_Click()
valore.Text = valore.Text & 2
End Sub

Private Sub tasto3_Click()
valore.Text = valore.Text & 3
End Sub

Private Sub tasto4_Click()
valore.Text = valore.Text & 4
End Sub

Private Sub tasto5_Click()
valore.Text = valore.Text & 5

End Sub

Private Sub tasto6_Click()
valore.Text = valore.Text & 6
End Sub

Private Sub tasto7_Click()
valore.Text = valore.Text & 7
End Sub

Private Sub tasto8_Click()
valore.Text = valore.Text & 8
End Sub

Private Sub tasto9_Click()
valore.Text = valore.Text & 9
End Sub

Private Sub UserForm_Click()

End Sub