Hello,

I just have made a calculator on VBA, including a simple financial function. Everything is working fine, but the value that is shown in the textbox dont take any format. And if i use this code -- Visor.Value = Format(Visor.Value, "#,#0.00") -- I just take this format number -- 1,234 (I am in Brazil, so we use comma to show the cents) -- anyone have any Idea of what I can do?

Here is the file with the calculator: Calculator.xlsm

Here is the Code I used (Feel Free to use it, if you improove the code just share...):

Dim limpar As String
Dim calculo As Currency
Dim tabela As Currency
Dim memoria As Currency
Dim Parc As Currency
Dim I As Currency
Dim PVa As Currency
Dim N As Currency
Private Sub but0_Click()
    Visor.Value = Visor.Value + "0"
    Visor.SetFocus
End Sub

Private Sub but1_Click()
    Visor.Value = Visor.Value + "1"
    Visor.SetFocus
End Sub

Private Sub but2_Click()
    Visor.Value = Visor.Value + "2"
    Visor.SetFocus
End Sub

Private Sub but3_Click()
    Visor.Value = Visor.Value + "3"
    Visor.SetFocus
End Sub

Private Sub but4_Click()
    Visor.Value = Visor.Value + "4"
    Visor.SetFocus
End Sub

Private Sub but5_Click()
    Visor.Value = Visor.Value + "5"
    Visor.SetFocus
End Sub

Private Sub but6_Click()
    Visor.Value = Visor.Value + "6"
    Visor.SetFocus
End Sub

Private Sub but7_Click()
    Visor.Value = Visor.Value + "7"
    Visor.SetFocus
End Sub

Private Sub but8_Click()
    Visor.Value = Visor.Value + "8"
    Visor.SetFocus
End Sub

Private Sub but9_Click()
    Visor.Value = Visor.Value + "9"
    Visor.SetFocus
End Sub

Private Sub butI_Click()

On Error GoTo Errado


If PVa > 0 And N > 0 And Parc > 0 Then

    I = Rate(N, Parc, PVa * -1)
    Visor.Value = ""
    Visor.Value = I
    Visor.SetFocus

    Else

    CheckBox2.Value = True
    I = Visor.Value / 100
    Visor.Value = ""
    Visor.SetFocus

End If

Errado:
CheckBox2.Value = False
MsgBox "Você Inseriu um Valor Inválido!", vbExclamation, "ATENÇÃO!!"
Exit Sub

End Sub

Private Sub butN_Click()

If PVa > 0 And I > 0 And Parc > 0 Then

    N = WorksheetFunction.NPer(I, Parc, PVa * -1)
    Visor.Value = ""
    Visor.Value = N
    Visor.SetFocus

    Else

    CheckBox4.Value = True
    N = Visor.Value
    Visor.Value = ""
    Visor.SetFocus

End If

End Sub

Private Sub butpercent_Click()

Visor.Value = Visor.Value / 100
Visor.SetFocus

End Sub

Private Sub butpmt_Click()

If N > 0 And I > 0 And PVa > 0 Then

    Parc = PMT(I, N, PVa * -1)
    Visor.Value = ""
    Visor.Value = Parc
    Visor.SetFocus
    
    Else
    
    CheckBox3.Value = True
    Parc = Visor.Value
    Visor.Value = ""
    Visor.SetFocus
    
End If

End Sub

Private Sub butpv_Click()

If N > 0 And I > 0 And Parc > 0 Then

    PVa = WorksheetFunction.PV(I, N, Parc)
    Visor.Value = ""
    Visor.Value = PVa
    Visor.SetFocus
    
    Else
    
    CheckBox1.Value = True
    PVa = Visor.Value
    Visor.Value = ""
    Visor.SetFocus

End If

End Sub

Private Sub butsinal_Click()
    Visor.Value = Visor.Value * "-1"
    Visor.SetFocus
End Sub


Private Sub separador_Click()
    Visor.Value = Visor.Value + ","
    Visor.SetFocus
End Sub

Private Sub resultado_Click()

    Select Case calculo
    
    Case 1
    Visor.Value = memoria * Visor.Value
    
    Case 2
    Visor.Value = memoria / Visor.Value
    
    Case 3
    Visor.Value = memoria + Visor.Value
    
    Case 4
    Visor.Value = memoria - Visor.Value
    
    Case Else
    MsgBox "Dígito inválido!"
    
    End Select
    
    Visor.SetFocus
    
End Sub

Private Sub butlimpar_Click()
    limpar = ""
    memoria = 0
    Visor.Value = limpar
    calculo = 0
    Parc = 0
    I = 0
    PVa = 0
    N = 0
    CheckBox1.Value = False
    CheckBox2.Value = False
    CheckBox3.Value = False
    CheckBox4.Value = False
End Sub

Private Sub butmultiplicar_Click()
    memoria = Visor.Value
    Visor.Value = ""
    calculo = 1
    Visor.SetFocus
End Sub

Private Sub butdividir_Click()
    memoria = Visor.Value
    Visor.Value = ""
    calculo = 2
    Visor.SetFocus
End Sub

Private Sub butsomar_Click()
    memoria = Visor.Value
    Visor.Value = ""
    calculo = 3
    Visor.SetFocus
End Sub

Private Sub butsubtrair_Click()
    memoria = Visor.Value
    Visor.Value = ""
    calculo = 4
    Visor.SetFocus
End Sub

Private Sub butCE_Click()
Visor.Value = ""
End Sub


Private Sub UserForm_Click()
Visor.SetFocus
End Sub
Private Sub visor_Change()
Visor.Value = Format(Visor.Value, "#,###.##0")
End Sub
Private Sub Visor_OnFocus()

'Visor.Value = Format(Visor.Value, "#,#0.00")

End Sub
Private Sub visor_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

'Visor.Value = Format(Visor.Value, "#,#0.00")

Select Case KeyAscii

    Case Is = 8
    KeyAscii = 0
    Call butCE_Click
    
    Case Is = 37
    KeyAscii = 0
    Call butpercent_Click

    Case Is = 42
    KeyAscii = 0
    Call butmultiplicar_Click

    Case Is = 43
    KeyAscii = 0
    Call butsomar_Click

    Case Is = 44
    KeyAscii = 0
    Call separador_Click

    Case Is = 45
    KeyAscii = 0
    Call butsubtrair_Click
    
    Case Is = 47
    KeyAscii = 0
    Call butdividir_Click
    
    Case Is = 48
    KeyAscii = 48
    
    Case Is = 49
    KeyAscii = 49
    
    Case Is = 50
    KeyAscii = 50
    
    Case Is = 51
    KeyAscii = 51
    
    Case Is = 52
    KeyAscii = 52
    
    Case Is = 53
    KeyAscii = 53
    
    Case Is = 54
    KeyAscii = 54
    
    Case Is = 55
    KeyAscii = 55
    
    Case Is = 56
    KeyAscii = 56
    
    Case Is = 57
    KeyAscii = 57
    
    Case Is = 61
    KeyAscii = 0
    Call resultado_Click

    Case Is = 61
    KeyAscii = 0
    Call resultado_Click

    Case Is = 127
    KeyAscii = 0
    Call butlimpar_Click

    Case Else
    KeyAscii = 0
    
End Select
    
End Sub