# convert values above 1000

## Recommended Posts

Good afternoon, someone could help me?

I'm trying to do one function, to eliminate points of values above 1000

eg

U\$ 1352,00

to

U\$ 1352,00

I was thinking of comparing the number of characters, and if larger than 11, use a stringleft and stringright and put them together, but I think there's an easier way to do ... if they can help me, I would greatly appreciate it!

thanks

##### Share on other sites

```Func MakeLessThan1000(\$money)
\$values = StringRegExp(\$money, "^U\\$ (\d+),(\d\d)\$", 1)
If @error Then Return \$money ; doesn't match for some reason...
\$number = \$values[0]
While \$number >= 1000
\$number -= 1000
WEnd
Return "U\$ " & \$number & "," & \$values[1]
EndFunc```

Wrote this up quickly. Haven't tested it. Give it the whole string of "U\$ 1352,00" and it will return "U\$ 352,00" as long as I did it right.

Edited by Richard Robertson

##### Share on other sites

thankyou for your repply, but i'm sorry, wrong in the description

right would be:

example value:

convert this

U\$ 1.352,00

to

U\$ 1352,00

is basically remove the point, that's

ps: I found the edit button in the post!

Edited by golfinhu

##### Share on other sites

Oh ok. Yeah I can change the code real quick. Lemme know if this one works.

```Func Fix(\$money)
\$values = StringRegExp(\$money, "^U\\$ (\d*).(\d+),(\d\d)\$", 1)
If @error Then Return \$money ; doesn't match for some reason...
Return "U\$ " & \$values[0] & \$values[1] & "," & \$values[2]
EndFunc```

##### Share on other sites

Oh ok. Yeah I can change the code real quick. Lemme know if this one works.

```Func Fix(\$money)
\$values = StringRegExp(\$money, "^U\\$ (\d*).(\d+),(\d\d)\$", 1)
If @error Then Return \$money ; doesn't match for some reason...
Return "U\$ " & \$values[0] & \$values[1] & "," & \$values[2]
EndFunc```

it's work, thankyou so much!

##### Share on other sites

You're welcome. There might be a better way to do it, but if what I did works, then it's fine.

##### Share on other sites

StringReplace the decimal point with ""?

Edited by darkjohn20

##### Share on other sites

StringReplace the decimal point with ""?

Now see, that's exactly what I'm talking about. Not once did that cross my mind.

##### Share on other sites

StringRegExp is quite slow compared to StringReplace, and is recommended when possible.

##### Share on other sites

Yeah I know it's slow. I just don't write in AutoIt anymore. I had forgotten the function.

## Create an account

Register a new account