VERSION 5.00 Begin VB.Form frmMoeda Caption = "Moeda ( versão 1 )" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 6750 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 6750 StartUpPosition = 3 'Windows Default Begin VB.Frame fraOpConversao Caption = "Seleccione Conversão" Height = 1575 Left = 3480 TabIndex = 5 Top = 360 Width = 2775 Begin VB.OptionButton optConversao Caption = "Euros para Escudos" Height = 375 Index = 1 Left = 240 TabIndex = 7 Top = 960 Width = 1815 End Begin VB.OptionButton optConversao Caption = "Escudos para Euros" Height = 375 Index = 0 Left = 240 TabIndex = 6 Top = 480 Value = -1 'True Width = 2295 End End Begin VB.CommandButton cmdConverter Caption = "Converter" Height = 495 Left = 360 TabIndex = 4 Top = 2280 Width = 1455 End Begin VB.TextBox txtEuros Height = 375 Left = 1200 TabIndex = 3 Top = 1200 Width = 1575 End Begin VB.TextBox txtEscudos Height = 375 Left = 1200 TabIndex = 1 Top = 480 Width = 1575 End Begin VB.Label lblEuros Caption = "Euros" Height = 375 Left = 240 TabIndex = 2 Top = 1200 Width = 975 End Begin VB.Label lblEscudos Caption = "Escudos" Height = 375 Left = 240 TabIndex = 0 Top = 480 Width = 975 End End Attribute VB_Name = "frmMoeda" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Const BRANCO = &H80000005 Const CINZENTO = &H8000000B Const ESCUDOS_PARA_EUROS = 0 Const EUROS_PARA_ESCUDOS = 1 Const TAXA_CONVERSAO_ESCUDO = 200.482 Dim ConversaoSeleccionada As Integer Dim LimparCaixaOutput As Boolean Private Sub Form_Load() ' É realizado no design time 'optConversao(0).Value = True Activa o optConversao_Click, e aí o SetFocus não funciona durante o Form Load txtEuros.Enabled = False txtEuros.BackColor = CINZENTO txtEuros.FontBold = True LimparCaixaOutput = False ConversaoSeleccionada = ESCUDOS_PARA_EUROS End Sub Private Sub optConversao_Click(Index As Integer) optConversao(Index).Value = True txtEscudos.Text = "" txtEuros.Text = "" ConversaoSeleccionada = Index Select Case Index Case 0 AlternaConversao txtEscudos, txtEuros Case 1 AlternaConversao txtEuros, txtEscudos End Select End Sub Private Sub cmdConverter_Click() Dim Valor As Double Select Case ConversaoSeleccionada Case ESCUDOS_PARA_EUROS If IsNumeric(txtEscudos) Then Valor = CDbl(txtEscudos.Text) Valor = Valor / TAXA_CONVERSAO_ESCUDO Valor = Round(Valor, 2) txtEuros.Text = CStr(Valor) + " €" LimparCaixaOutput = True Else MsgBox "Erro na introdução dos dados" End If txtEscudos.SetFocus Case EUROS_PARA_ESCUDOS If IsNumeric(txtEuros) Then Valor = CDbl(txtEuros.Text) Valor = Valor * TAXA_CONVERSAO_ESCUDO Valor = Round(Valor) txtEscudos.Text = FormatCurrency(Valor) LimparCaixaOutput = True Else MsgBox "Erro na introdução dos dados" End If txtEuros.SetFocus End Select End Sub Private Sub AlternaConversao(txtActivada As TextBox, txtDesactivada As TextBox) txtActivada.Enabled = True txtActivada.BackColor = BRANCO txtActivada.FontBold = False txtDesactivada.Enabled = False txtDesactivada.BackColor = CINZENTO txtDesactivada.FontBold = True txtActivada.SetFocus End Sub Private Sub txtEscudos_Change() If LimparCaixaOutput Then LimparCaixaOutput = False txtEuros.Text = "" End If End Sub Private Sub txtEuros_Change() If LimparCaixaOutput Then LimparCaixaOutput = False txtEscudos.Text = "" End If End Sub