I have a label that displays information from my database and I need to format it. It displays a number format like so: (53389) and I just need it to display (53,389)
it uses the SQL to COUNT or SUM the data from the datasource.

My first question is, is there a way to have it format like I want when it is displayed, or do I need to change the data format in the database?

here is my code:

        Catch ex As Exception
        End Try

            Dim arx As Integer
            arx = MainDataSet.Tables("MAIN").Rows.Count
            Dim cmd As OleDbCommand = New OleDbCommand("SELECT SUM(BurnSize) FROM MAIN", con)
            Dim cmd2 As OleDbCommand = New OleDbCommand("SELECT COUNT(BurnSize) FROM MAIN", con)

                Dim acrestotal As Int32 = cmd.ExecuteScalar
                Dim burnscount As Int32 = cmd2.ExecuteScalar
                Label1.Text = "There are " & burnscount & " burns in the database for " & acrestotal & " total acres."

            Catch ex As Exception
                MsgBox("Error getting data!", MsgBoxStyle.Information, "Error...")
            End Try

        Catch ex As Exception
        End Try

Label1.text is what I am wanting to format, both the variables.

Label1.Text = String.Format("There are {0:#,##0} burns in the database for {1:#,##0} total acres.", burnscount, acrestotal);


Be a part of the DaniWeb community

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