Michaeljep
(Michael Jeppesen)
October 30, 2024, 12:21pm
1
Hi
What is the best approach to identify the format a number is returned in?
The output of a REST response, is a string containing different numbers, I want to do a greater/lower than comparison with a static number.
But the output can be written like 7.500 or 7500 or 7500.00 or 7500,00
If I remove the . period char in 7.500 and also in 7500.00, one of the number will be incorrect.
So how can I verify the number format and make sure that they are all compared as 7500 units?
Br
Michael
@Michaeljep
Try replacing ,
with .
using this.
StrInput= StarInput.Replace(",",".")
Now convert the string to double using this
dblVariable=CDbl(StrInput)
Now do the comparison. Make sure your another variable or value you are comparing this also should be double datatype.
dblVariable > 7.500
@Michaeljep
Also, you can try the activity “Format Value”
SorenB
October 30, 2024, 4:01pm
4
Hello @Michaeljep
If the number has trailing digits, will it always be two characters?
7500,00 and 7500.00 ?
If so, then you could check whether the number .EndsWith “.00” or “,00” and then remove the last 3 characters.
After this you can remove all commas and dots, before you make the comparison.
Regards
Soren
sppal.c
(Sppal C)
October 31, 2024, 5:52am
5
@Michaeljep you can try this solution.
Replace all the “.” with “,”
Find the last index of “,” and replace it with “.”
Remove all the “,” from you string
Convert you string value to double that will give you the accurate number.