ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I get a number in such a format as it should be? (https://www.excelbanter.com/excel-programming/361765-can-i-get-number-such-format-should.html)

OrientalPearl

Can I get a number in such a format as it should be?
 
Howday everyone,

Just a quick question here. How can I disable scientific notation to
kick in when manipulating a variable in VBA, i.e. to display/use/...
its value as 123456789123456789 as exactly it should be rather than
1.23E+18. Basically scientific notation needs to be totally switched
off here. The variable is of type Single by the way.

Many thanks
Frank


tchid2

Can I get a number in such a format as it should be?
 
Try the Format() formula. Something like:

Let vMyVar = Format(vMyVar, "00000000000000000.0")

HTH,
tchid2


"OrientalPearl" wrote:

Howday everyone,

Just a quick question here. How can I disable scientific notation to
kick in when manipulating a variable in VBA, i.e. to display/use/...
its value as 123456789123456789 as exactly it should be rather than
1.23E+18. Basically scientific notation needs to be totally switched
off here. The variable is of type Single by the way.

Many thanks
Frank



OrientalPearl

Can I get a number in such a format as it should be?
 
Thanks for the solution, tchid2. The other thing I didn't make clear is
that it's a variable, i.e. its value is unknown, can be 999 or
999999999999999999999999. So Im not exactly sure whether Format() can
do this or not since I dont really know how many 0s I should place
there. Is another more generic way to totally toss scientific notation
out of the window regardless of the number of digits??

Appreciate your help!
Frank


OrientalPearl

Can I get a number in such a format as it should be?
 
I have figured out the solution myself, which is provided here and
hopefully will of some help to others in the futu
It's not complicated really...just need to declare the variable 'AS
Variant', which will keep the numeric representation all the time (well
before its boundary values are exceeded)
Good luck to everyone involved in VBA



All times are GMT +1. The time now is 12:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com