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

Bruce Steers bsteers4 at gmail.com
Sun Mar 26 18:03:25 CEST 2023


On Sun, 26 Mar 2023 at 17:00, Bruce Steers <bsteers4 at gmail.com> wrote:

>
>
> On Sat, 25 Mar 2023 at 22:39, 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
>>
>
>
> What about
>

oops , had a wrong var name in there

Print GetFloat("$98,765.43")

Public Sub GetFloat(sVal As String) As Float

  Return CFloat(Split(sVal, "£$,").Join(""))

End
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230326/76f99641/attachment.htm>


More information about the User mailing list