News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Use the FormatCurrency function

Started by nandagopal, Nov 07, 2008, 08:21 PM

Previous topic - Next topic

nandagopal

This example uses the following code to display these examples in a TextBox.


Private Sub Form_Load()
    Dim txt As String
    Dim x As Single

    txt = ""
    x = 1.23456
    txt = txt & "FormatCurrency(" & Format$(x) & ", 2) = " _
        & FormatCurrency(x, 2) & vbCrLf

    x = 0.123456
    txt = txt & "FormatCurrency(" & Format$(x) & ", 2, " & _
        "vbFalse) = " & FormatCurrency(x, 2, vbFalse) & _
        vbCrLf
    txt = txt & "FormatCurrency(" & Format$(x) & ", 2, " & _
        "vbTrue) = " & FormatCurrency(x, 2, vbTrue) & vbCrLf

    x = -12345.12345
    txt = txt & "FormatCurrency(" & Format$(x) & ", , " & _
        "vbFalse) = " & FormatCurrency(x, 2, , vbFalse) & _
        vbCrLf
    txt = txt & "FormatCurrency(" & Format$(x) & ", , " & _
        "vbTrue) = " & FormatCurrency(x, 2, , vbTrue) & _
        vbCrLf
    txt = txt & "FormatCurrency(" & Format$(x) & ", , " & _
        "vbTrue, vbFalse) = " & FormatCurrency(x, 2, , _
        vbTrue, vbFalse) & vbCrLf

    txtResults.Text = txt
End Sub