How to extract the Decimal value of a string?

Hi all!

I’m trying to get the value of a string.
In some cases it works if I use VAL.

But I got some values in string like $5,200,000.00 but cuz of this “$” I can’t get the value of this.

I wonder if theres a way to parse the number and remove the “$” sign and then do it a VAL to get the value.

Thanks

Use ReplaceAll to get get rid of the commas and dollar signs in the string before passing it to VAL.

So, if your money string is ‘money’, replace the $ signs and commas with empty strings

cleanmoney=money.ReplaceAll(",","").ReplaceAll("$", "")

etc…

See http://documentation.xojo.com/index.php/ReplaceAll

Thanks man, :smiley: :smiley:

De nada. Buena suerte…!

[quote=213562:@Richard Brown]Use ReplaceAll to get get rid of the commas and dollar signs in the string before passing it to VAL.

So, if your money string is ‘money’, replace the $ signs and commas with empty strings

cleanmoney=money.ReplaceAll(",","").ReplaceAll("$", "")

etc…

See http://documentation.xojo.com/index.php/ReplaceAll[/quote]

Removing the dollar sign is enough if you use Cdbl() instead of Val()

dim myDouble as Double = Cdbl(money.ReplaceAll("$", ""))