How do I display the results of a calculated field in scientific notation.
Is this possible. Thanks in advance.
There are no facilities in Word's numeric formatting switch to produce
results in scientific notation. You could probably produce a sequence of {
IF } fields that would do it if you knew your exponents were going to fall
within a reasonably small range, but otherwise, I think you need to find a
way to use the Format function in VBA, which can do it - for example
format(1234.5,"0.00E+00")
returns
1.23E+03
{ IF
so the question is how to get VBA to process your number. That depends on
what you're doing - if it's a one-off, it might be enough simply to create a
VBA macro that formats the selected text.
A possible approach is to nest your field inside a DATABASE field. If you're
using Word 2003 and probably 2002, you should be able to do the following
{ DATABASE \d "C:\\a\\a.mdb" \s "SELECT format(1234.5,'0.00E+00')" }
where a.mdb is valid Access .mdb file (it doesn't need to have any tables in
it).
If the field you want to format is, e.g.
{ =1234.5 }
then nest it, e.g.
{ DATABASE \d "C:\\a\\a.mdb" \s "SELECT format({ =1234.5 },'0.00E+00')" }
wher all the {} are the field braces you can insert using ctrl-F9
In theory, because you are only returning a single row and column, Word does
not put the result in a table. But in Word 2003 I've noticed that the
DATABASE field can insert an additional paragraph mark which may make this
approach unusable.
Peter Jamieson
> How do I display the results of a calculated field in scientific notation.
> Is this possible. Thanks in advance.
Hi Mark,
The following compound field will return the scientific notation of any +ve
value between 10^-9 and 10^9:
{QUOTE
{SET a {SourceVal}}
{SET
b{=9-(a<10^9)-(a<10^8)-(a<10^7)-(a<10^6)-(a<10^5)-(a<10^4)-(a<10^3)-(a<10^2)
-(a<10^1)-(a<10^0)-(a<10^-1)-(a<10^-2)-(a<10^-3)-(a<10^-4)-(a<10^-5)-(a<10^-
6)-(a<10^-7)-(a<10^-8)}}
{SET c{=int(a/10^b)+mod(a,10^b)/10^b}}
{c \# 0.00}E{b \# +00;-00}}
where 'SourceVal' is the input, which could be a formula taking its input
from two formfields. You can extend the range easily enough by adding more
terms.
All the field braces (i.e. { }) are created in pairs via Ctrl-F9. I've laid
the coding out with line breaks to separate the key portions of the coding,
but you don't really need them.
Cheers
> How do I display the results of a calculated field in scientific notation.
> Is this possible. Thanks in advance.