[Gambas-user] Convert a "currency" string to a number

Jussi Lahtinen jussi.lahtinen at gmail.com
Sun Mar 26 00:03:26 CET 2023


I would do something like this:
cfloat(replace(right(sTotal, -1), ",", ""))

However, I do not know how much there is variation in the string format.
You may need to use Trim() and take localization into account.


Jussi

On Sun, Mar 26, 2023 at 12:39 AM BB <adamnt42 at gmail.com> wrote:

> What's the best way to convert a string that looks like "$98,765" or
> "$98,765.43" to an integer / float?
>
> Or putting this another way, I want to test if the value is > something
> (like "sTotal > 50000"), what is the most efficient way to do this check.
>
> tia
>
> bruce
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230326/4deec307/attachment.htm>


More information about the User mailing list