hi,

how do i format the currency value. i have used Format(GrandTotal, "0.00") but i still got output like this 60917.3972.
How can i make it to 60917.40

Recommended Answers

All 7 Replies

hi

i have tried Format(CDbl(GrandTotal), "0.00") and even Format(CDbl(GrandTotal), "#,###,###.00") but the result still the same. How do i make it only 2 decimal

This should work OK.

Can you put the entire piece of code and signal what and where you are testing to obtain the wrong result?

Thanks in advance

hi,

this is my code. In sql database i set to float

Public Function Update_RetailerData() As Double
        Dim myConnection As SqlConnection
        Dim myCommand As SqlCommand
        Dim icount As Integer
        Dim strSQL As String = ""
        Dim connStr As String

        myConnection = GetConnectCRLimit("REMOTE")
        myConnection.Open()

    Form1.txtEncryptCode.Text & "','" & frmCurrentBalance.lblTopUp.Text & "')"
    strSQL = "UPDATE RetailerBalance SET BoothID='" & BoothNo & "'WHERE GrandTotal='" & Format(CDbl(GrandTotal), "0.00") & "'"

    Form1.txtBoothID.Text & "'AND AuthorizationCode='" & Form1.txtEncryptCode.Text & "'"

        myCommand = New SqlCommand(strSQL, myConnection)
        icount = myCommand.ExecuteNonQuery()

    myConnection.Close()

    End Function

Two issues:
1) if GrandTotal is a float in the DB, do not surround the number with quotes in the SQL sentence
2) Searching on a float is generally not a good idea, because the internal precission representation of exponent and mantissa.

Please, can you be so kind to indicate what is the contents of strSQL before executing the SQL command?

Thanks in advance

hi,

do you mean that i shouldn't use float if i want to get result of 2 decimal value in currency value

Better use Decimal.

thank you. its working well now after change to decimal

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.