Euroconvertitore

 

 

 

Il codice è il seguente :

Private Sub chiudi_Click(Index As Integer)
'La funzione "end" serve per chiudere l'applicazione
End
End Sub

Private Sub Command1_Click(Index As Integer)
'Inserisce i valori dei numeri della tastiera
'nelle rispettivi Text selezionati tramite gli Option
If Option1.Value = True Then
Text1.Text = Val(Text1.Text + Command1(Index).Caption)
Else
Text2.Text = Val(Text2.Text + Command1(Index).Caption)
End If
End Sub



Private Sub Command3_Click(Index As Integer)
'Cancella i rispettivi Text
If Option1.Value = True Then
'Cancella Text1
Text1.Text = ""
'Imposta Text1 come predefinito
Text1.SetFocus
'Cancella T2ext
Text2 = ""
End If
If Option2.Value = True Then
'Cancella Text2
Text2.Text = ""
'Imposta Text2 come predefinito
Text2.SetFocus
'Cancella Text1
Text1 = ""
End If
End Sub

Private Sub Form_Load()
'Imposta l'opzione Lira come default
Option1.Value = True
'Imposta la Text1 come non bloccata
Text1.Locked = False
'Imposta l'opzione Euro come non default
Option2.Value = False
'Imposta la Text2 come bloccata
Text2.Locked = True
'Cancella la Text1
Text1.Text = ""
Label1(0).ForeColor = &HFF&
Option1.ForeColor = &HFF&
End Sub


Private Sub Option1_Click()
Text1.SetFocus
Option1.Value = True
Text1.Locked = False
Option2.Value = False
Text2.Locked = True
Text1 = ""
Text2 = ""
Label1(0).ForeColor = &HFF&
'colore rosso= &HFF&
Option1.ForeColor = &HFF&
'colore ciano =&HFFFF00
'colore nero=
Label1(1).ForeColor = &H0&
Option2.ForeColor = &H0&
End Sub

Private Sub Option2_Click()
Text2 = ""
Text1 = ""
Text2.SetFocus
Option1.Value = False
Text1.Locked = True
Option2.Value = True
Text2.Locked = False
Label1(0).ForeColor = &H0&
Option1.ForeColor = &H0&
Label1(1).ForeColor = &HFF&
Option2.ForeColor = &HFF&

End Sub

Private Sub Text1_Change()
If Option1.Value = True Then
'Esegue la conversione da Lire ad Euro del text1 convertendo anche la valuta
Text2.Text = Format(Val(Text1.Text) / 1936.27, "##,##0.00")
'Visualizza il messaggio se si immette un valore elevato
If Val(Text1) > 9000000000000# Then
MsgBox "Importo non valido", 16, "Errore di digitazione"
Text1 = ""
Text2.Text = ""
Text1.SetFocus
End If
End If
End Sub



Private Sub Text2_Change()
If Option2.Value = True Then
'Esegue la conversione da Euro a Lire del text2 convertendo la valuta
Text1.Text = Format(Val(Text2.Text) * 1936.27, "##,##0.00")
'Visualizza il messaggio se si immette un valore elevato
If Val(Text2) > 90000000# Then
MsgBox "Importo non valido", 16, "Errore di digitazione"
Text2 = ""
Text1.Text = ""
Text2.SetFocus
End If
End If
End Sub