# Formatting a Number in Listbox (DBkit)

**URL:** <https://forum.xojo.com/t/formatting-a-number-in-listbox-dbkit/83944>\
**Category:** Databases\
**Created:** [January 17, 2025, 1:21pm UTC](https://forum.xojo.com/t/formatting-a-number-in-listbox-dbkit/83944 "2025-01-17T13:21:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yann\_DUPONT](https://forum.xojo.com/letter_avatar_proxy/v4/letter/y/3be4f8/32.png) [@Yann\_DUPONT](https://forum.xojo.com/u/Yann_DUPONT)\
**Post date:** [January 17, 2025, 1:21pm UTC](https://forum.xojo.com/t/formatting-a-number-in-listbox-dbkit/83944/1 "2025-01-17T13:21:45Z")

</div>

Hi there,

Using the Desktop example provided with Xojo, I am trying with no success to figure out how to format the Amount column as “monetary” (like $ 123,456.00).

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [January 17, 2025, 2:19pm UTC](https://forum.xojo.com/t/formatting-a-number-in-listbox-dbkit/83944/2 "2025-01-17T14:19:39Z")

</div>

> [@Yann\_DUPONT](#):
>
> I am trying with no success to figure out how to format the Amount column as “monetary” (like $ 123,456.00).

if you share what you tried…

Currency is the name.

Why $ ?

Check locale

How the values are stored in the DB ?

---

<div class="post-metadata">

**Author:** ![Scott\_C](https://forum.xojo.com/user_avatar/forum.xojo.com/scott_c/32/19612_2.png) [@Scott\_C](https://forum.xojo.com/u/Scott_C)\
**Post date:** [January 17, 2025, 5:52pm UTC](https://forum.xojo.com/t/formatting-a-number-in-listbox-dbkit/83944/3 "2025-01-17T17:52:34Z")

</div>

> [@Yann\_DUPONT](#):
>
> I am trying with no success to figure out how to format the Amount column as “monetary” (like $ 123,456.00).

To get the results you want, it will depend on the datatype of the source value, i.e., `Integer`, `Double` or `Currency`, and what [locale](https://documentation.xojo.com/api/os/locale.html) you are outputting (whether local or another region).

```auto
Var testFRlocale As New Locale("fr-FR") // for example purposes

Var tmpInt As Integer = 123456
Me.AddRow(tmpInt.ToString(Locale.Raw, "$ #,###.00")) // $ 123,456.00
Me.AddRow(tmpInt.ToString(Locale.Current, "$ #,###.00")) // results depend on your region
Me.AddRow(testFRlocale.CurrencySymbol + tmpInt.ToString(testFRlocale, " #,###.00")) // € 123 456,00

Var tmpDbl As Double = 123456.0
Me.AddRow(tmpDbl.ToString(Locale.Raw, "$ #,###.00")) // $ 123,456.00
Me.AddRow(tmpDbl.ToString(Locale.Current, "$ #,###.00")) // results depend on your region
Me.AddRow(testFRlocale.CurrencySymbol + tmpDbl.ToString(testFRlocale, " #,###.00")) // € 123 456,00

Var tmpCur As Currency = 123456.0
Me.AddRow(tmpCur.ToString(Locale.Raw)) // 123456
Me.AddRow(tmpCur.ToString(Locale.Current)) // results depend on your region
Me.AddRow(tmpCur.ToString(testFRlocale)) // 123 456,00 €

```

There is also the [Format()](https://documentation.xojo.com/api/text/format.html) function, but that depends on whether you’re concerned about displaying a specific locale formatting.

---

<div class="post-metadata">

**Author:** ![Yann\_DUPONT](https://forum.xojo.com/letter_avatar_proxy/v4/letter/y/3be4f8/32.png) [@Yann\_DUPONT](https://forum.xojo.com/u/Yann_DUPONT)\
**Post date:** [January 17, 2025, 6:38pm UTC](https://forum.xojo.com/t/formatting-a-number-in-listbox-dbkit/83944/4 "2025-01-17T18:38:35Z")

</div>

I used the Dollar monetary sign as I supposed many users where from USA.

My code is as follow:

```auto
//Load the invoices for this customer
Var IDinvoice As Integer = row.Column(Me.PrimaryKeyColumn).IntegerValue

SearchResultsLignesFacture.RemoveAllRows

Var rs As RowSet = Me.Connection.SelectSQL("SELECT * FROM " + TableConnectionLignesFacture.Table + " WHERE InvoiceNo = ?", IDinvoice.ToString)

// AFFICHAGE DES FACTURES LIEES A LA PERSONNE AFFICHEE
SearchResultsLignesFacture.QueryRows = rs

Return True

```

The value stored in the DB is Float type

---

<div class="post-metadata">

**Author:** ![Yann\_DUPONT](https://forum.xojo.com/letter_avatar_proxy/v4/letter/y/3be4f8/32.png) [@Yann\_DUPONT](https://forum.xojo.com/u/Yann_DUPONT)\
**Post date:** [January 17, 2025, 6:39pm UTC](https://forum.xojo.com/t/formatting-a-number-in-listbox-dbkit/83944/5 "2025-01-17T18:39:06Z")

</div>

If I understand well I can’t use my code to format the values as monetary but I have to loop the records in the RowSet?

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [January 17, 2025, 7:07pm UTC](https://forum.xojo.com/t/formatting-a-number-in-listbox-dbkit/83944/6 "2025-01-17T19:07:04Z")

</div>

> [@Yann\_DUPONT](#):
>
> monetary

Currency is the correct word.

I already shared it in this forum, but you will learn a lot from it (use current version to open / read / execute it).

It creates a Data Base file, save Currency (as €), dates as Italian format, etc. and read / display the whole back to a ListBox.  
[Currency in SQLite.zip](https://forum.xojo.com/uploads/short-url/aJamOUyOEktNMj2XWHEIg9uPmrp.zip) (11.0 KB)

At last, you my want to use not only $, but some other like €. So, knowing to use Locale is required.

Of course, your software, your design / requirements.

---

<div class="post-metadata">

**Author:** ![Usha\_vilash](https://forum.xojo.com/letter_avatar_proxy/v4/letter/u/b5a626/32.png) [@Usha\_vilash](https://forum.xojo.com/u/Usha_vilash)\
**Post date:** [January 18, 2025, 8:09am UTC](https://forum.xojo.com/t/formatting-a-number-in-listbox-dbkit/83944/7 "2025-01-18T08:09:10Z")

</div>

Hi Yann, did you try looping through the RowSet and formatting each value before adding it to the ListBox? Also, are you using a specific Locale for currency formatting, or do you want it to adapt to the user’s region automatically?

---

<div class="post-metadata">

**Author:** ![Yann\_DUPONT](https://forum.xojo.com/letter_avatar_proxy/v4/letter/y/3be4f8/32.png) [@Yann\_DUPONT](https://forum.xojo.com/u/Yann_DUPONT)\
**Post date:** [January 18, 2025, 4:04pm UTC](https://forum.xojo.com/t/formatting-a-number-in-listbox-dbkit/83944/8 "2025-01-18T16:04:01Z")

</div>

Hello Usha,

No, I was trying to use the DBkit only

```auto
SearchResultsLignesFacture.QueryRows = rs

```
