It is currently 28 February 2021, 4:11 Advanced search

values getting trimmed

Questions and answers on how to best use Instant Developer

values getting trimmed

Postby john w » 30 December 2020, 19:50

I have a csv that I have converted to a json file. I then read values based on a key. I need to populate those values into a text box on a panel. When the values are passed the trailing zeros are deleted in the text box. Debug shows the correct values, in the panel they are trimmed of the trailing zeros. Any idea why this is the case and the solution?
See images


Ashampoo_Snap_2020.12.30_13h43m19s_001_.png
Ashampoo_Snap_2020.12.30_13h43m19s_001_.png (30.11 KiB) Viewed 88 times


Ashampoo_Snap_2020.12.30_13h43m39s_002_.png
Ashampoo_Snap_2020.12.30_13h43m39s_002_.png (27.15 KiB) Viewed 88 times
Regards

John W
User avatar
john w
 
Posts: 629
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA

Re: values getting trimmed

Postby d.termini » 31 December 2020, 7:34

Hello John,
do the textboxes have the correct data type / visual style / mask?
Also when you get a number from a string you may need to cast it because strange things may happen with the IDVariants, you can use toCurrency(m.GetValue("123")) in this case, this may fix everything.
d.termini
 
Posts: 887
Joined: 13 November 2017, 8:41

Re: values getting trimmed - Solved

Postby john w » 31 December 2020, 15:03

d.termini

Thanks for the suggestions. I have tried conversions toInteger, toFloat, toString, etc. All trim the trailing zeros (0). The only thing I have found that works it to change the IMDB data fields to string, then pass the values using toString(). The problem with that is I then have to cast the string back to a number. It seems to add some unnecessary code.

I have also set masks and visual styles. They have not worked. I am back to look at it today with hopes I have missed something.

It goes without saying that when doing calculations there is a huge difference between 325 and 325,000.

This seems like a bug, its certainly not a feature...

Thanks again!

UPDATE: The solution is to use the StringToNumber function. Conversion using other methods does not seem to work.
Regards

John W
User avatar
john w
 
Posts: 629
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA


Return to Tips & Tricks

Who is online

Users browsing this forum: No registered users and 7 guests

cron