Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Values greater than a million

Status
Not open for further replies.

David Higgs

Programmer
May 6, 2012
392
GB
Hi,
In my application I would like to display for example 7.160000
(7.16 MHz) as 7.160.000 in my Grid /Form , is this feasible?

Regards,
David
 
Yes, there is TRANSFORM for this, or the Textbox Format and Inputmask properties.

You just have to comprehend, that the US format code for decimal point is the piont and separators are commas, but you get 7.160.000 having such regional formats set up in Windows regional settings about number formatting and using SET SYSFORMATS ON.

So you do ? Transform(71600000,"@R 999,999,999") and get 7.160.000 on eg a german system and 7,160,000 on a US or UK system. The way to enforce a separator and decimal point would be SET SEPARATOR TO and SET POINT TO, where you can specify any chars, not only switch comma and point. If you aim to please worldwide, simply use the SYSFORMATS and don't enforce a certain format. And just to be very clear, even if you set the separator to "." the inputmask code for a separator always stays "," and the same goes for TRANSFORM. On a similar level VAL() always expects a "." as decimal point and can't cope with a "," inside a number, it'll neither take that as german decimal point nor as US/UK separator of magnitude groups of large numbers, so for VAL used on such a formatted number the separators always have to be stripped off and the decimal point has to be a point.

Bye, Olaf.
 
Hello Olaf,

Thank you for your very informative reply, most helpful.

My application will eventually "poll" (via COM Port) a receivers frequency in MHz and display this on a Form and also store the value in a Table.

Regards,
David
 
In regard of polling: I do the same for electronic scales and depending on the scale settings I get numbers with comma or point as decimal point. I take RAT(".", input) and RAT(",", input) and take the least one as separator to stripe off first, then take the highest one as decimal point to always convert it to "." for VAL.

So eg "1.000,10 g" comes in, "." has the lower position than "," and so I take "." as separator and stripe it off, getting "1000,10 g" then turn "," to ".", getting "1000.10 g" and can take the VAL of that. Besides I turn kg and mg as factors of 1000 and 1/1000 respectively, you can convert units like Mhz kHz in the same manner, obviously. So you really have a little parser for the real value in Hz as I have for weights in grams.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top