Formatted TextField conversion to CDBL

I am displaying in a textfield a double formatted as Format(dTemp, "\\$##,###.00")

Then at record update time I am converting the value back to a double using CDBL - except with the $ it fails to convert.

How do I easily strip out the formatting before converting to a double?


make a small method “ToDouble” that extends a string, removes the “$” and returns the cdbl you need.

is not so necessary use currency sign in the field…
U can create a New TextField class

  1. Create a new class
    name : CurrencyField
    super : TextField

  2. Press right mouse button ( or equal in mac os ) on the new TextField Class and select 'Add to ‘CurrencyField’ and select ‘Shared Computed Propery’ named the new property with ‘Currencyvalue’

  3. in Set Method add this code :

me.text = Format(value, "\\$-#,###,###,###.00")
  1. in Get Methos add this code :
return replace(me.text,"§","").CDbl

Now insert in your project this new CurrencyField and please, use “Currency” type for variable currency NOT DOUBLE cause double value leave a scrapt in calc ( eg: discount or vat etc… ).

For use in code, U have put a new contror CurrencyField named field1
for assign a value use :

field1.currencyvalue = 100.00

for read value use :

price = field1.currencyvalue

is simple …
‘Ciao’ From Italy, Max.

1 Like

At 4th point U can use in get method :

return me.text.toDouble