0

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

2
Contributors
7
Replies
9
Views
6 Years
Discussion Span
Last Post by swathys
0

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

Edited by swathys: n/a

0

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

0

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

Edited by swathys: n/a

0

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

Edited by lolafuertes: n/a

0

hi,

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

This question has already been answered. Start a new discussion instead.
Be sure to adhere to our posting rules.