Android Question Problem class module table.bas currency

puang

Member
I have sqlite database with table and field.
Example :
nametable : SalesTables
field1 : |FieldId| number|
field2 : |FieldBookName| text|
field3 : |FieldPrice| currency|

| Id|BookName|Price |
|1 |abc |$10.000|

I build apk database to listview ( but use it class module Table.bas )

Problem : Table1 in Layout
| Id|BookName|Price |
|1 |abc |10000|

Expectation : Table1 in Layout
| Id|BookName|Price |
|1 |abc |$10.000 |
 

klaus

Expert
Licensed User
Longtime User
It is not possible to do it directly.
It could be done after having loaded the database and then adding the $ sign with UpdateCell.

Or as a workaround you could do this:
Expectation : Table1 in Layout
| Id|BookName|Price $|
|1 |abc |10.000 |
 
Upvote 0

puang

Member
It is not possible to do it directly.
It could be done after having loaded the database and then adding the $ sign with UpdateCell.

Or as a workaround you could do this:
Expectation : Table1 in Layout
| Id|BookName|Price $|
|1 |abc |10.000 |
the way (code) 10000 to 10.000
if 100 = 100
if 1000 = 1.000
if 10000 = 10.000
if 100000 = 100.000
if 1000000 = 1.000.000
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
You need to modify the cells after having filled the Table:
B4X:
Private col, row As Int
col = 2  'the index of the column to modify
For row = 0 To Table2.NumberOfRows - 1
    Private Value As Double
    Private sValue As String
    Value = Table2.GetValue(col, row)  'gets the cell value and transforms it into a String
    sValue = "$ " & NumberFormat2(Value, 1, 0, 0, True)   'formats the value into a string
    sValue = sValue.Replace(",", ".")  'replaces the commas by dots.
    Table2.SetValue(col, row, sValue)  'sets the new value in the cell
Next
 
Upvote 0
Top