4
votes

Hi I want to get numbers from database, for example, if the number in database is 44.7890000000, I would like to get a string 44.789, the same 0.0010000000 -> 0.001, just keep the numbers and trim the tailing '0'. I use this code: qrySth.Fields[i].AsString - it does its job but I find for very small numbers like 0.0000010000 it becomes 1E-6. Is there a way I could disable the scientific notation for this AsString method?

Thanks!

1
I think maybe I need to use displayformat - spspli
You should add that comment as an answer, Spspli. - Rob Kennedy
Is there a way I use AsString, but can control its display to non-scientific number? - spspli
'DisplayFormat' does not change what 'AsString' returns, it only effects the GetText method of the field which is used in data aware controls. - Sertac Akyuz
Related for other languages: Haskell Lua C++ ostreams Delphi - Mechanical snail

1 Answers

2
votes

As an alternative to setting the field's DisplayFormat property, you can read from AsFloat and pass the value directly to FormatFloat. It uses the same format pattern.